org.apache.tapestry.form.validator
Interface Validator

All Superinterfaces:
FormComponentContributor
All Known Implementing Classes:
AbstractValidatorWrapper, BaseValidator, BeanValidatorWrapper, Email, Identity, Max, MaxDate, MaxLength, Min, MinDate, MinLength, Pattern, Required

public interface Validator
extends FormComponentContributor

An object that can be "attached" to a IFormComponent to perform server-side validation (validate(IFormComponent, ValidationMessages, Object)) as well as generate cleint-side validation (in the form of JavaScript submit listeners).

Since:
4.0
Author:
Paul Ferraro

Method Summary
 boolean getAcceptsNull()
          Returns true if this validator accepts null as the object parameter to validate().
 boolean isRequired()
          Returns true if this field is required.
 void validate(IFormComponent field, ValidationMessages messages, Object object)
          Invoked to validate input for the field.
 
Methods inherited from interface org.apache.tapestry.form.FormComponentContributor
renderContribution
 

Method Detail

validate

void validate(IFormComponent field,
              ValidationMessages messages,
              Object object)
              throws ValidatorException
Invoked to validate input for the field. A Translator will have already converted the submitted user input string into an object.

Parameters:
field - the form element component being validated, often used to determine the user presentable name for the field, used in error messages.
messages - access to the pre-defined validation messages, in the appropriate locale
object - the client-side representation of the field's data. May be null if the client did not provide a value for the field (most Validators should check for null and perform no check if null).
Throws:
ValidatorException - if the object violates the constraint represented by this Validator.

getAcceptsNull

boolean getAcceptsNull()
Returns true if this validator accepts null as the object parameter to validate(). When the object is null, validators that can't accept null are skipped. It is rare for a validator to return true.


isRequired

boolean isRequired()
Returns true if this field is required. Returns false otherwise.



Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.