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

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

/**
 * 发票状态校验器
 *
 * @author Gqr
 * @since 2025/8/21 14:37
 */
public class InvoiceStatusValidtor implements ConstraintValidator<InvoiceStatusValid, Integer> {
    @Override
    public boolean isValid(Integer integer, ConstraintValidatorContext constraintValidatorContext) {
        if (ObjectUtil.isNull(integer)) {
            return true;
        }
        for (InvoiceStatusEnum invoiceStatusEnum : InvoiceStatusEnum.values()) {
            if (invoiceStatusEnum.getCode().equals(integer)) {
                return true;
            }
        }
        return false;
    }
}
