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

import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.module.system.enums.sms.SmsReceiveStatusEnum;

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

/**
 * 短信接收状态校验器
 *
 * @author Gqr
 * @since 2024/10/15 13:47
 */
public class SmsReceiveStatusValidator implements ConstraintValidator<SmsReceiveStatusValid, Integer> {
    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        if (ObjectUtil.isNull(value)) {
            return true;
        }
        for (SmsReceiveStatusEnum statusEnum : SmsReceiveStatusEnum.values()) {
            if (ObjectUtil.equal(statusEnum.getStatus(), value)) {
                return true;
            }
        }
        return false;
    }
}
