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


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

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


/**
 * @author 排单状态校验器
 */
public class PlanStatusValidator implements ConstraintValidator<PlanStatusValid, Integer> {

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

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

        for (PlanStatusEnum statusEnum : PlanStatusEnum.values()) {
            if (ObjectUtil.equal(statusEnum.getStatus(), value)) {
                return true;
            }
        }

        return false;


    }
}
