Package org.javalite.validation
Interface Validatable
- All Known Implementing Classes:
Book
,JSONBase
,Model
,ModelRegistry
,ValidationSupport
public interface Validatable
Top interface to make something validatable.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFailedValidator(Validator validator, String errorKey)
This method is not to add validators for future processing.errors()
Provides an instance of localizedErrors
object, filled with error messages after validation.Provides an instance of localizedErrors
object, filled with error messages after validation.Used by validators to get valuesboolean
isValid()
Implementation should call {#link validate()} internally.void
validate()
Runs validation.void
validate(boolean reset)
Runs validation.
-
Method Details
-
get
Used by validators to get values- Parameters:
attribute
- name of attribute- Returns:
- value of attribute
-
addFailedValidator
This method is not to add validators for future processing. This is instead used to add validators and their respective error messages in case those validators fail.- Parameters:
validator
- validator that failed validation (later to be used to retrieve error message)errorKey
- - generally an attribute name that failed validation
-
isValid
boolean isValid()Implementation should call {#link validate()} internally.- Returns:
- true if object is valid.
-
validate
void validate()Runs validation. Will blow away any previous validation errors. -
validate
void validate(boolean reset)Runs validation.- Parameters:
reset
- true to reset all previous validation errors.
-
errors
Errors errors()Provides an instance of localizedErrors
object, filled with error messages after validation.- Returns:
- an instance of localized
Errors
object, filled with error messages after validation.
-
errors
Provides an instance of localizedErrors
object, filled with error messages after validation.- Parameters:
locale
- locale to pick the right resource bundle.- Returns:
- an instance of localized
Errors
object, filled with error messages after validation.
-