package com.ruoyi.common.validRule.allowSize;

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

/**
 * 判断列表大小
 * @author wjh
 * 2024/6/13
 */
@Documented
@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE })
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(AllowSize.List.class)
@Constraint(validatedBy = { AllowSizeValidator.class })
public @interface AllowSize {
    String message() default "{*.validation.constraint.Enum.message}";

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

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

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

    /**
     * 是否过滤null的元素
     */
    boolean filterNull() default true;

    /**
     * 允许的大小
     */
    int[] sizes() default {};

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