Module io.avaje.validation
Package io.avaje.validation.adapter
Annotation Interface ConstraintAdapter
Marks a type as a Constraint Adapter to be registered automatically.
A custom adapter registered using this annotation must have a public constructor accepting a ValidationContext instance, and must extend the AbstractConstraintAdapter/ValidationAdapter class.
Example:
invalid input: '{@code
@ConstraintAdapter(SomeAnnotation.class)
public final class CustomAnnotationAdapter extends AbstractConstraintAdapter<Object> {
String value;
public CustomAnnotationAdapter(AdapterCreateRequest req) {
//create a message object for error interpolation and set groups
super(req);
//use the attributes to extract the annotation values
value = (String) req.attribute("value");
}
@Override
public boolean isValid(Object value) {
var isValid = ...custom validation based on the attributes;
return isValid;
}
}</pre>'
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionClass
<? extends Annotation> The Annotation this validator targets
-
Element Details
-
value
Class<? extends Annotation> valueThe Annotation this validator targets
-