package com.cf.imes.module.system.validation.operatelog;

import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum;

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

/**
 * 操作日志类型校验器
 *
 * @author Gqr
 * @since 2024/10/15 15:49
 */
public class OperateLogTypeValidator implements ConstraintValidator<OperateLogTypeValid, Integer> {
    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        if (ObjectUtil.isNull(value)) {
            return true;
        }
        for (OperateTypeEnum typeEnum : OperateTypeEnum.values()) {
            if (ObjectUtil.equal(typeEnum.getType(), value)) {
                return true;
            }
        }
        return false;
    }
}
