Annotation Type Pattern


@Target(FIELD) @Retention(RUNTIME) public @interface Pattern
Annotation used to validate a string for given regEx pattern. By default, it doesn't have any value. Because of this a value

must

be supplied for usage. * Example usage: *
  * 
  * public class UserDto {
  *     @Pattern("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$")
  *     private String email;
  * }
  * 
  * 
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
     
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
     
  • Element Details

    • value

      String value
    • message

      String message
      Default:
      "Field must follow the pattern!"