A
- The annotation typeT
- The supported validation types@Indexed(value=ConstraintValidator.class) @FunctionalInterface public interface ConstraintValidator<A extends Annotation,T> extends ConstraintValidator<A,T>
Constraint
instances. Allows defining validators that work with both Hibernate validator and Micronaut's validator.
Unlike the specification's interface this one can uses as a functional interface. Implementor should not implement the ConstraintValidator.initialize(Annotation)
method and should instead read the passed AnnotationValue
.
Modifier and Type | Field and Description |
---|---|
static ConstraintValidator |
VALID
A constraint validator that just returns the object as being valid.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isValid(T value,
AnnotationValue<A> annotationMetadata,
ConstraintValidatorContext context)
Implements the validation logic.
|
default boolean |
isValid(T value,
ConstraintValidatorContext context) |
initialize
static final ConstraintValidator VALID
boolean isValid(@Nullable T value, @NonNull AnnotationValue<A> annotationMetadata, @NonNull ConstraintValidatorContext context)
Implementations should be thread-safe and immutable.
value
- object to validateannotationMetadata
- The annotation metadatacontext
- The context objectfalse
if value
does not pass the constraintdefault boolean isValid(T value, ConstraintValidatorContext context)
isValid
in interface ConstraintValidator<A extends Annotation,T>