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


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

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

/**
 * @author 包裹类型校验器
 */
public class PackTypeValidator implements ConstraintValidator<PackTypeValid, Integer> {


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

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

        for (OrderPackageTypeEnum typeEnum : OrderPackageTypeEnum.values()) {
            if (ObjectUtil.equal(typeEnum.getType(), value)) {
                return true;
            }
        }

        return false;
    }
}
