package com.cf.imes.module.executor.validation.manage.pack;

import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.common.enums.OrderPackageStatusEnum;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * @author 打包状态校验器
 */
public class OrderPackagedValidator implements ConstraintValidator<OrderPackagedStatusValid, Integer> {

    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext constraintValidatorContext) {

        if (ObjectUtil.isNull(value)) {
            return true;
        }

        for (OrderPackageStatusEnum statusEnum : OrderPackageStatusEnum.values()) {
            if (ObjectUtil.equal(statusEnum.getStatus(), value)) {
                return true;
            }
        }

        return false;

    }
}
