public abstract class BaseValidator<T> extends Object implements Validator<T>
| Constructor and Description |
|---|
BaseValidator() |
| Modifier and Type | Method and Description |
|---|---|
String |
getInvalidMessage(T value)
A user message explaining why the value is not valid if it fails this validation rule.
|
boolean |
isValid(T value)
Determines if the non-null value is valid according to the rule this validator enforces.
|
abstract boolean |
isValidWithoutNull(T value)
Same as isValid, but no null checking is needed.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetInvalidSpecificationMessage, getTheValueMustDescription, isSpecificationValidpublic boolean isValid(T value) throws IllegalArgumentException
Validator
Implementations should check for null and throw an IllegalArgumentException, since some
types of validation operations may fail to detect a null and simply return false.
Loaders (which call Validators) is a probable user extension point, so consistent
handling and rejection of null values is important for custom Loaders to detect logic
issues.
isValid in interface Validator<T>value - A non-null value of type 'T'.IllegalArgumentException - If the value is null.public abstract boolean isValidWithoutNull(T value)
value - The value, which is guaranteed to not be null.public String getInvalidMessage(T value)
ValidatorThe message should only refer to the value and rule criteria, and assume it is presented in a context that has already indicated an error and the Property. No leading or trailing punctuation should not be included.
Example: The value '999999999' is larger than the max value of 9999
getInvalidMessage in interface Validator<T>value - The value which failed validation. Not null.Copyright © 2022. All rights reserved.