lundi 28 août 2017

Validating Controller classes in java using @Pattern annotation for multiple strings

I am validating a java class using @Pattern annotation from Deadbolt. I want to give access if either of these strings are present : 'TM_TASK' OR 'TM_CHECKLIST'. Right now i am a little confused as to how to provide these strings inside @Pattern so that it gives access if the string matches either of those 2 strings.I am also open to using regex (although i am new to them) as to how to verify if it is any of those 2 strings ('TM_TASK' OR 'TM_CHECKLIST') using Regex and not any other invalid string.

e.g.

@Api(value = "/tasks")
@Pattern(value = "^[a-zA-Z0-9_]*$", patternType = PatternType.REGEX)
public class TaskController extends BaseController {

  private static Logger.ALogger log = Logger.of(TaskController.class);
  private TaskService taskService;
  private FormFactory formFactory;
}

Aucun commentaire:

Enregistrer un commentaire