Package dev.morphia.query.validation
Class ValueValidator
- java.lang.Object
-
- dev.morphia.query.validation.ValueValidator
-
- All Implemented Interfaces:
Validator
- Direct Known Subclasses:
KeyValueTypeValidator,ListValueValidator,PatternValueValidator
public abstract class ValueValidator extends java.lang.Object implements Validator
Provides validation based on the Value in the query
-
-
Constructor Summary
Constructors Constructor Description ValueValidator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanapply(java.lang.Class<?> type, java.lang.Object value, java.util.List<ValidationFailure> validationFailures)Applied validation for the given field.protected abstract java.lang.Class<?>getRequiredValueType()Used byapplyto figure out whether to apply the validation or simply return.protected abstract voidvalidate(java.lang.Class<?> type, java.lang.Object value, java.util.List<ValidationFailure> validationFailures)
-
-
-
Method Detail
-
apply
public boolean apply(java.lang.Class<?> type, java.lang.Object value, java.util.List<ValidationFailure> validationFailures)Applied validation for the given field. If the value does not match the correct type, the validation is not applied and this method returns false. If the value is to be validated, then the validate method is called to see if the value and type are compatible. Errors are appended to the validationFailures list.- Parameters:
type- the Class of the field being queriedvalue- the non-null value being used for a queryvalidationFailures- the list to add any failures to. If validation passes orappliesToreturned false, this list will not change.- Returns:
- true if validation was applied, false if this validation doesn't apply to this field type.
-
getRequiredValueType
protected abstract java.lang.Class<?> getRequiredValueType()
Used byapplyto figure out whether to apply the validation or simply return.- Returns:
- the class the value should be in order to go ahead and perform validation
-
validate
protected abstract void validate(java.lang.Class<?> type, java.lang.Object value, java.util.List<ValidationFailure> validationFailures)
-
-