mellowdeep

@password

Nov 7th, 2016
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. package com.homework.annotations;
  2.  
  3. import java.lang.annotation.Documented;
  4. import java.lang.annotation.ElementType;
  5. import java.lang.annotation.Retention;
  6. import java.lang.annotation.RetentionPolicy;
  7. import java.lang.annotation.Target;
  8.  
  9. import javax.validation.Constraint;
  10. import javax.validation.Payload;
  11. import javax.validation.constraints.Pattern;
  12.  
  13. @Pattern.List({ @Pattern(regexp = "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\\s).{4,30}$",message = "Invalid Password") })
  14. @Constraint(validatedBy = {})
  15. @Documented
  16. @Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE,
  17.         ElementType.CONSTRUCTOR, ElementType.PARAMETER })
  18. @Retention(RetentionPolicy.RUNTIME)
  19. public @interface Password {
  20.     String message() default "{invalid.password}";
  21.  
  22.     Class<?>[] groups() default {};
  23.  
  24.     Class<? extends Payload>[] payload() default {};
  25.  
  26.     @Target({ElementType.METHOD,
  27.         ElementType.FIELD,
  28.         ElementType.ANNOTATION_TYPE,
  29.         ElementType.CONSTRUCTOR,
  30.         ElementType.PARAMETER})
  31.     @Retention(RetentionPolicy.RUNTIME)
  32.     @Documented
  33.     @interface List {
  34.         Password[] value();
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment