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

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

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


/**
 * @author 板材排孔类型校验器
 */
public class PlatePlaceHoleValidator implements ConstraintValidator<PlatePlaceHoleValid, Integer> {

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

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

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

        return false;

    }
}
