package com.cf.imes.module.executor.validation.plate;


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

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

/**
 * @author 板材类型校验器
 */
public class PlateTypeValidator implements ConstraintValidator<PlateTypeValid, Integer> {


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

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

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

        return false;
    }
}
