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

import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.common.enums.StatisticsUnit;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * 资金统计维度单位入参校验器
 *
 * @author Gqr
 * @since 2024/7/17 9:33
 */
public class FundsStatisticsUnitInEnumValidator implements ConstraintValidator<FundsStatisticsUnitInEnum, Integer> {

    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        if (ObjectUtil.isNull(value)) {
            return true;
        }
        StatisticsUnit unit = StatisticsUnit.fromValue(value);
        return ObjectUtil.isNotNull(unit);
    }

}

