java.lang.Object
org.apache.wicket.validation.Validatable<T>
- Type Parameters:
T
- type of validatable
- All Implemented Interfaces:
IValidatable<T>
This implementation of
IValidatable
is meant to be used outside of Wicket. It allows
other parts of the application to utilize IValidator
s for validation.
Example:
class WebService
{
public void addUser(String firstName, String lastName)
{
Validatable standin = new Validatable();
standin.setValue(firstName);
new FirstNameValidator().validate(standin);
standing.setValue(lastName);
new LastNameValidator().validate(standin);
if (!standin.isValid())
{
// roll your own ValidationException
throw new ValidationException(standin.getErrors());
}
else
{
// add user here
}
}
}
- Since:
- 1.2.6
- Author:
- Igor Vaynberg (ivaynberg)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
error
(IValidationError error) Reports an error against thisIValidatable
's value.Retrieves an unmodifiable list of any errors reported against thisIValidatable
instance.getModel()
Returns the model of the component being validatedgetValue()
Retrieves the value to be validated.boolean
isValid()
Queries the current state of thisIValidatable
instance.void
Sets modelvoid
Sets the value object that will be returned bygetValue()
.
-
Constructor Details
-
Validatable
public Validatable()Constructor. -
Validatable
Constructor.- Parameters:
value
- The value that will be tested
-
-
Method Details
-
setModel
Sets model- Parameters:
model
-
-
setValue
Sets the value object that will be returned bygetValue()
.- Parameters:
value
- the value object
-
getValue
Description copied from interface:IValidatable
Retrieves the value to be validated.- Specified by:
getValue
in interfaceIValidatable<T>
- Returns:
- the value to be validated
- See Also:
-
error
Description copied from interface:IValidatable
Reports an error against thisIValidatable
's value. Multiple errors can be reported by calling this method multiple times.- Specified by:
error
in interfaceIValidatable<T>
- Parameters:
error
- anIValidationError
to be reported- See Also:
-
getErrors
Retrieves an unmodifiable list of any errors reported against thisIValidatable
instance.- Returns:
- an unmodifiable list of errors
-
isValid
Description copied from interface:IValidatable
Queries the current state of thisIValidatable
instance.IValidatable
s should assume they are valid untilIValidatable.error(IValidationError)
is called.- Specified by:
isValid
in interfaceIValidatable<T>
- Returns:
true
if the object is in a valid state,false
if otherwise- See Also:
-
getModel
Description copied from interface:IValidatable
Returns the model of the component being validated- Specified by:
getModel
in interfaceIValidatable<T>
- Returns:
- component's model
-