1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| package com.ruben.validator;
import com.ruben.enumration.GenderEnum;
import javax.validation.Constraint; import javax.validation.Payload; import javax.validation.ReportAsSingleViolation; import javax.validation.constraints.NotNull; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*; import static java.lang.annotation.RetentionPolicy.RUNTIME;
@NotNull @Documented @Retention(RUNTIME) @Constraint(validatedBy = {GenderValidator.class}) @ReportAsSingleViolation @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE}) public @interface Gender { String message() default "性别应该为:男1 女0";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
GenderEnum[] value();
}
|