package com.cf.imes.module.executor.validation.manage.parts;

import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.module.executor.enums.manage.parts.CategoryEnum;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import java.util.Objects;

/**
 * 配件主类校验
 */
public class PartsCategoryValidator implements ConstraintValidator<PartsCategoryValid, String> {

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (ObjectUtil.isNull(value)) {
            return true;
        }
        for (CategoryEnum categoryEnum : CategoryEnum.values()) {
            if (Objects.equals(categoryEnum.getValue(), value)) {
                return true;
            }
        }
        return false;
    }

}
