package com.cf.imes.module.system.validation.recharge;

import cn.hutool.core.util.ObjectUtil;

import com.cf.imes.module.system.enums.recharge.RechargeGiftTypeEnum;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import java.util.Objects;

/**
 * 赠送类型校验器
 */
public class RechargeGiftTypeValidator implements ConstraintValidator<RechargeGiftTypeValid, Integer> {

    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        if (ObjectUtil.isNull(value)) {
            return true;
        }
        for (RechargeGiftTypeEnum statusEnum : RechargeGiftTypeEnum.values()) {
            if (Objects.equals(statusEnum.getStatus(), value)) {
                return true;
            }
        }
        return false;
    }
}
