Package org.hawaiiframework.validation
Interface Validator<T>
-
- Type Parameters:
T
- the type of the object to validate
public interface Validator<T>
A validator for validating application-specific objects.This interface is inspired on Spring's
Validator
mechanism. However Hawaii's validator mechanism uses it's ownValidationResult
instead of Spring'sErrors
for returning validation errors.Implementors should typically only implement
validate(Object, ValidationResult)
as other methods are already implemented using the interface's default methods.- Since:
- 2.0.0
- Author:
- Marcel Overdijk
- See Also:
ValidationError
,ValidationException
,ValidationResult
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default boolean
isValid(T object)
Returnstrue
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.
-
-
-
Method Detail
-
validate
default ValidationResult validate(T object)
Validates the supplied object.- Parameters:
object
- the object to validate- Returns:
- the validation result
-
validate
void validate(T object, ValidationResult validationResult)
Validates the supplied object.- Parameters:
object
- the object to validatevalidationResult
- the contextual state about the validation process
-
validateAndThrow
default void validateAndThrow(T object) throws ValidationException
Validates the supplied object.- Parameters:
object
- the object to validate- Throws:
ValidationException
- if the validation fails
-
validateAndThrow
default void validateAndThrow(T object, ValidationResult validationResult) throws ValidationException
Validates the supplied object.- Parameters:
object
- the object to validatevalidationResult
- the contextual state about the validation process- Throws:
ValidationException
- if the validation fails
-
isValid
default boolean isValid(T object)
Returnstrue
if the validation of the supplied object succeeds.- Parameters:
object
- the object to validate- Returns:
true
if the validation of the supplied object succeeds
-
-