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

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

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