自定义注解@IsMobile (1)

 1 import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
 2 import static java.lang.annotation.ElementType.CONSTRUCTOR;
 3 import static java.lang.annotation.ElementType.FIELD;
 4 import static java.lang.annotation.ElementType.METHOD;
 5 import static java.lang.annotation.ElementType.PARAMETER;
 6 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 7 
 8 import java.lang.annotation.Documented;
 9 import java.lang.annotation.Retention;
10 import java.lang.annotation.Target;
11 
12 import javax.validation.Constraint;
13 import javax.validation.Payload;
14 
15 @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
16 @Retention(RUNTIME)
17 @Documented
18 @Constraint(validatedBy = {IsMobileValidator.class })
19 public @interface  IsMobile {
20     
21     boolean required() default true;
22     
23     String message() default "手机号码格式错误";
24 
25     Class[] groups() default { };
26 
27     Classextends Payload>[] payload() default { };
28 }

 

转载于:https://www.cnblogs.com/Alexhuangqing/p/9471977.html

你可能感兴趣的:(自定义注解@IsMobile (1))