package com.zd.common.core.valid;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * 枚舉自定義驗證
 *
 * @Author: zhoupan
 * @Date: 2021/09/03/9:16
 * @Description:
 */
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(validatedBy = EnumStringValidator.class)//标明由哪个类执行校验逻辑
public @interface EnumString {

    String message() default "值错误!";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    /**
     * @return 映射的枚举类， 如果有该值存在，则代表该枚举的所有值都参与验证
     */
    Class<?> value();

    /**
     * @return 手动指定候选值，转为string判断
     */
    String[] stringValue() default {};
}
