T
- the type of the object to validatepublic interface Validator<T>
This interface is inspired on Spring's Validator
mechanism. However Hawaii's validator mechanism uses it's own ValidationResult
instead of
Spring's Errors
for returning validation errors.
Implementors should typically only implement validate(Object, ValidationResult)
as other methods are already implemented using the interface's default methods.
ValidationError
,
ValidationException
,
ValidationResult
Modifier and Type | Method and Description |
---|---|
default boolean |
isValid(T object)
Returns
true if the validation of the supplied object succeeds. |
default ValidationResult |
validate(T object)
Validates the supplied object.
|
void |
validate(T object,
ValidationResult validationResult)
Validates the supplied object.
|
default void |
validateAndThrow(T object)
Validates the supplied object.
|
default void |
validateAndThrow(T object,
ValidationResult validationResult)
Validates the supplied object.
|
default ValidationResult validate(T object)
object
- the object to validatevoid validate(T object, ValidationResult validationResult)
object
- the object to validatevalidationResult
- the contextual state about the validation processdefault void validateAndThrow(T object) throws ValidationException
object
- the object to validateValidationException
- if the validation failsdefault void validateAndThrow(T object, ValidationResult validationResult) throws ValidationException
object
- the object to validatevalidationResult
- the contextual state about the validation processValidationException
- if the validation failsdefault boolean isValid(T object)
true
if the validation of the supplied object succeeds.object
- the object to validatetrue
if the validation of the supplied object succeeds