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


import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.module.system.enums.advertisement.AdvertisementStatusEnum;

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

/**
 * 广告状态校验器
 *
 * @author 晨丰科技
 */
public class AdvertisementStatusValidator implements ConstraintValidator<AdvertisementStatus, Integer> {

    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        if (ObjectUtil.isNull(value)) {
            return true;
        }
        for (AdvertisementStatusEnum statusEnum : AdvertisementStatusEnum.values()) {
            if (Objects.equals(statusEnum.getStatus(), value)) {
                return true;
            }
        }
        return false;
    }

}
