package com.greenorange.promotion.annotation;


import com.greenorange.promotion.model.enums.UserRoleEnum;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;


// 枚举校验器
public class UserEnumValidator implements ConstraintValidator<UserEnumValue, String> {


    @Override
    public void initialize(UserEnumValue constraintAnnotation) {

    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        return UserRoleEnum.getEnumByValue(value) != null;
    }
}
