- Type Parameters:
T
- The type of value to be validated
- All Known Implementing Classes:
AbstractConstraintAdapter
,ContainerAdapter
,PrimitiveAdapter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
This interface defines a set of validation methods for validating a value based on specific
rules. The methods in this interface allow for executing validations, composing validation
adapters, and checking validation groups.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Validation adapter that supports and uses the primitive type. -
Method Summary
Modifier and TypeMethodDescriptiondefault ValidationAdapter
<T> andThen
(ValidationAdapter<? super T> after) Compose this validation adapter with another adapter by applying the validations in sequence.default ContainerAdapter
<T> array()
Create an adapter for validating an array.default boolean
checkGroups
(Set<Class<?>> adapterGroups, ValidationRequest request) Check if the validation request groups are empty or match any of the adapter's configured groups.default ContainerAdapter
<T> list()
Create an adapter for validating a list of values.default ContainerAdapter
<T> mapKeys()
Create an adapter for validating map keys.default ContainerAdapter
<T> Create an adapter for validating map values.default ContainerAdapter
<T> optional()
Create an adapter for validating an optional value.default ValidationAdapter.Primitive
Return a primitive adapter.default boolean
validate
(T value, ValidationRequest req) Execute validations for the given valueboolean
validate
(T value, ValidationRequest req, String propertyName) Execute validations for the given value.
-
Method Details
-
validate
Execute validations for the given value.- Parameters:
value
- The value to be validatedreq
- The validation request containing group/locale/violation informationpropertyName
- The name of the property being validated- Returns:
true
if validation should continue,false
otherwise
-
validate
Execute validations for the given value- Parameters:
value
- The value to be validatedreq
- The validation request containing group/locale/violation information- Returns:
true
if validation should continue,false
otherwise
-
primitive
Return a primitive adapter. Supports int, long with Range, Min, Max, Positive. -
list
Create an adapter for validating a list of values.- Returns:
- The adapter for list validation
-
mapKeys
Create an adapter for validating map keys.- Returns:
- The adapter for map key validation
-
mapValues
Create an adapter for validating map values.- Returns:
- The adapter for map value validation
-
array
Create an adapter for validating an array.- Returns:
- The adapter for array validation
-
optional
Create an adapter for validating an optional value.- Returns:
- The adapter for optional value validation
-
andThen
Compose this validation adapter with another adapter by applying the validations in sequence.- Parameters:
after
- The validation adapter to be applied after this adapter- Returns:
- The composed validation adapter
- Throws:
NullPointerException
- ifafter
is null
-
checkGroups
Check if the validation request groups are empty or match any of the adapter's configured groups.- Parameters:
adapterGroups
- The groups configured for this adapterrequest
- The validation request containing the groups to be checked- Returns:
true
if the groups match or if the validation request groups are empty,false
otherwise
-