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


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

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

/**
 * @author 排单类型校验器
 */
public class PlanTypeValidator implements ConstraintValidator<PlanTypeValid, Integer> {


    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext constraintValidatorContext) {
        if (ObjectUtil.isNull(value)) {
            return true;
        }

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

        return false;
    }
}
