forked from kidgrow-microservices-platform

zhaoxiaohao
2020-11-17 b7265cdd6f3e1fbb0d428c27e5b5e29e34d56953
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
41
42
43
44
45
46
47
48
49
50
51
52
package com.kidgrow.common.annotation;
 
/**
 * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br>
 *
 * @Description: <br>
 * @Project: <br>
 * @CreateDate: Created in 2020/4/3 11:40 <br>
 * @Author: <a href="4345453@kidgrow.com">liuke</a>
 */
 
import com.kidgrow.common.utils.KidgrowDateValidator;
 
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
 
@Documented
// 指定该注解可以使用的地方
@Target(value = {ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
// 指定实际进行校验的校验器,该校验器是自己写的且必须实现ConstraintValidator接口
@Constraint(validatedBy = KidgrowDateValidator.class)
public @interface DateValidator {
    /**
     * 时间不早于
     * @return
     */
    String minDate() default "";
 
    /**
     * 时间不晚于
     * @return
     */
    String maxDate() default "";
 
    /**
     * 时间格式定义
     * @return
     */
    String pattern() default "yyyy-MM-dd";
 
    /**
     * 没加default给定默认值,使用注解的时候该属性必须赋值,否则报错
     * @return
     */
    String message();
 
    Class<?>[] groups() default {};
 
    Class<? extends Payload>[] payload() default {};
}