package com.ruoyi.system.valid;


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

/**
 * 枚举值校验注解
 * @author wjh
 * 2023/10/20
 */
@Documented
@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE })
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(DictValid.List.class)
@Constraint(validatedBy = { DictValidator.class })
public @interface DictValid {

	String message() default "{*.validation.constraint.Enum.message}";

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

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

	/**
	 * 字典类型
	 */
	String type();

	/**
	 * 是否允许null值，默认是允许
	 */
	boolean allowNull() default true;

	@Documented
	@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE })
	@Retention(RetentionPolicy.RUNTIME)
	@interface List {
		DictValid[] value();
	}
}
