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

import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.module.system.enums.recharge.RechargeTypeEnum;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import java.util.Objects;

/**
 * 充值类型校验器
 */
public class RechargeTypeValidator implements ConstraintValidator<RechargeType, Integer> {
    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        if (ObjectUtil.isNull(value)) {
            return true;
        }
        for (RechargeTypeEnum statusEnum : RechargeTypeEnum.values()) {
            if (Objects.equals(statusEnum.getStatus(), value)) {
                return true;
            }
        }
        return false;
    }
}
