Package org.hawaiiframework.validation
Interface Validator<T>
- Type Parameters:
T
- the type of the object to validate
- All Known Implementing Classes:
JakartaValidationValidator
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 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.
- Since:
- 2.0.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Returnstrue
if the validation of the supplied object succeeds.default ValidationResult
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 Details
-
validate
Validates the supplied object.- Parameters:
object
- the object to validate- Returns:
- the validation result
-
validate
Validates the supplied object.- Parameters:
object
- the object to validatevalidationResult
- the contextual state about the validation process
-
validateAndThrow
Validates the supplied object.- Parameters:
object
- the object to validate- Throws:
ValidationException
- if the validation fails
-
validateAndThrow
Validates the supplied object.- Parameters:
object
- the object to validatevalidationResult
- the contextual state about the validation process- Throws:
ValidationException
- if the validation fails
-
isValid
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
-