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


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

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

/**
 * @author 板材纹路校验器
 */
public class PlateTextureValidator implements ConstraintValidator<PlateTextureValid, Integer> {


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

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

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

        return false;

    }
}
