-
public interface DataSearchValidator
Interface to specify a FieldExpression Validator.
Add the DataSearchValidator implementation to a SearchDescriptor:
fun personSearchDescriptor(): SearchDescriptor<Person> = SearchDescriptorBuilder.builder<Person>() .validators(MyValidator()) .build()
-
-
Method Summary
Modifier and Type Method Description Boolean
supports(FieldExpression fieldExpression)
Checks if the given FieldExpression is supported by the validator. Unit
validateSingle(Object value, FieldExpression fieldExpression, DataSearchErrors errors)
Override this method to validate the given single value related to the FieldExpression. Unit
validateCollection(Collection<Object> values, FieldExpression fieldExpression, DataSearchErrors errors)
Override this method to validate the given collection of values related to the FieldExpression. Unit
validate(Collection<FieldExpression> fieldExpressions, DataSearchErrors errors)
Validates the given FieldExpressions. -
-
Method Detail
-
supports
Boolean supports(FieldExpression fieldExpression)
Checks if the given FieldExpression is supported by the validator.
- Parameters:
fieldExpression
- FieldExpression to check
-
validateSingle
Unit validateSingle(Object value, FieldExpression fieldExpression, DataSearchErrors errors)
Override this method to validate the given single value related to the FieldExpression.
The given DataSearchErrors instance can be used to report any resulting validation errors.
- Parameters:
value
- single value to be validated.fieldExpression
- FieldExpression related to the valueerrors
- DataSearchErrors instance used to report any resulting validation errors
-
validateCollection
Unit validateCollection(Collection<Object> values, FieldExpression fieldExpression, DataSearchErrors errors)
Override this method to validate the given collection of values related to the FieldExpression.
The default behavior is to iterate over values and call validateSingle for each value.
The given DataSearchErrors instance can be used to report any resulting validation errors.
- Parameters:
values
- collection of values to be validated.fieldExpression
- FieldExpression related to the valueserrors
- DataSearchErrors instance used to report any resulting validation errors
-
validate
Unit validate(Collection<FieldExpression> fieldExpressions, DataSearchErrors errors)
Validates the given FieldExpressions.
The default behavior:
Iterate over FieldExpressions,
Filter the FieldExpressions according to the supports method
Calls validateCollection if the FieldExpression.value is an instance of Collection, otherwise calls validateSingle.
This method can be overridden to change the default behavior.
-
-
-
-