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
Validatormechanism. However Hawaii's validator mechanism uses it's ownValidationResultinstead of Spring'sErrorsfor 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 booleanisValid(T object)Returnstrueif the validation of the supplied object succeeds.default ValidationResultvalidate(T object)Validates the supplied object.voidvalidate(T object, ValidationResult validationResult)Validates the supplied object.default voidvalidateAndThrow(T object)Validates the supplied object.default voidvalidateAndThrow(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)
Returnstrueif the validation of the supplied object succeeds.- Parameters:
object- the object to validate- Returns:
trueif the validation of the supplied object succeeds
-
-