com.bld.commons.utils.validator.AllowedValueValidator Maven / Gradle / Ivy
package com.bld.commons.utils.validator;
import java.lang.annotation.Annotation;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
/**
* The Class AllowedValueValidator.
*
* @param the generic type
* @param the generic type
*/
public abstract class AllowedValueValidator implements ConstraintValidator{
public final static String DEFAULT_MESSAGE="The value is not valid.";
/**
* Gets the message.
*
* @return the message
*/
protected abstract String getMessage();
/**
* Sets the context.
*
* @param valid the valid
* @param context the context
*/
protected void setContext(boolean valid,ConstraintValidatorContext context) {
if (!valid) {
context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate(this.getMessage()).addConstraintViolation();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy