|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Validator<C,T>
Used by a Field
to enforce a constraint related to a form submission. Validators themselves
are stateless singletons.
FieldValidator
.
FieldValidationSupport
,
FieldValidatorDefaultSource
Method Summary | |
---|---|
Class<C> |
getConstraintType()
Returns the type of constraint value used with this validator. |
String |
getMessageKey()
Returns the message key, within the validation messages, normally used by this validator. |
Class<T> |
getValueType()
Returns the value type associated with this validator. |
boolean |
isRequired()
Returns true if the validator should be invoked for null or blank (empty string) values. |
void |
render(Field field,
C constraintValue,
MessageFormatter formatter,
MarkupWriter writer,
FormSupport formSupport)
Hook used by components to allow the validator to contribute additional attributes or (more often) client-side JavaScript (via the FormSupport.addValidation(Field, String, String, Object) ). |
void |
validate(Field field,
C constraintValue,
MessageFormatter formatter,
T value)
Invoked after the client-submitted value has been translated to check
that the value conforms to expectations (often, in terms of minimum or maximum value). |
Method Detail |
---|
Class<C> getConstraintType()
Class<T> getValueType()
validate(Field, Object, MessageFormatter, Object)
will only be invoked when the value is assignable to the validator's value type.
String getMessageKey()
MessageFormatter
passed to validate(Field, Object, MessageFormatter, Object)
(unless
overridden).
void validate(Field field, C constraintValue, MessageFormatter formatter, T value) throws ValidationException
translated
to check
that the value conforms to expectations (often, in terms of minimum or maximum value). If and only if the value
is approved by all Validators is the value applied by the field.
field
- the field for which a client submitted value is being validatedconstraintValue
- the value used to constrainformatter
- Validation messages, in the appropriate localevalue
- the translated value supplied by the user
ValidationException
- if the value violates the constraintboolean isRequired()
Field.isRequired()
property.
void render(Field field, C constraintValue, MessageFormatter formatter, MarkupWriter writer, FormSupport formSupport)
FormSupport.addValidation(Field, String, String, Object)
).
field
- the field which is currently being renderedconstraintValue
- the value used to constrain inputformatter
- validation message, in the appropriate localewriter
- markup writer, allowing additional attributes to be written into the active elementformSupport
- used to add JavaScript
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |