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

import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.module.system.enums.pay.InvoiceTypeEnum;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * 发票类型校验器
 *
 * @author Gqr
 * @since 2025/8/21 14:37
 */
public class InvoiceTypeValidtor implements ConstraintValidator<InvoiceTypeValid, Integer> {
    @Override
    public boolean isValid(Integer integer, ConstraintValidatorContext constraintValidatorContext) {
        if (ObjectUtil.isNull(integer)) {
            return true;
        }
        for (InvoiceTypeEnum invoiceTypeEnum : InvoiceTypeEnum.values()) {
            if (invoiceTypeEnum.getValue().equals(integer)) {
                return true;
            }
        }
        return false;
    }
}
