org.apache.tapestry.valid
Interface IValidator

All Known Implementing Classes:
BaseValidator, DateValidator, EmailValidator, NumberValidator, PatternValidator, StringValidator, UrlValidator

public interface IValidator

An object that works with an IFormComponent to format output (convert object values to strings values) and to process input (convert strings to object values and validate them).

Since:
1.0.8
Version:
$Id: IValidator.java 243791 2004-02-19 17:38:13Z hlship $
Author:
Howard Lewis Ship

Method Summary
 boolean isRequired()
          All validators must implement a required property.
 void renderValidatorContribution(IFormComponent field, IMarkupWriter writer, IRequestCycle cycle)
          Invoked by the field after it finishes rendering its tag (but before the tag is closed) to allow the validator to provide a contribution to the rendering process.
 Object toObject(IFormComponent field, String input)
          Converts input, submitted by the client, into an object value.
 String toString(IFormComponent field, Object value)
          Invoked during rendering to convert an object value (which may be null) to a String.
 

Method Detail

isRequired

boolean isRequired()
All validators must implement a required property. If true, the client must supply a non-null value.


toString

String toString(IFormComponent field,
                Object value)
Invoked during rendering to convert an object value (which may be null) to a String. It is acceptible to return null. The string will be the VALUE attribute of the HTML text field.


toObject

Object toObject(IFormComponent field,
                String input)
                throws ValidatorException
Converts input, submitted by the client, into an object value. May return null if the input is null (and the required flag is false).

The input string will already have been trimmed. It may be null.

Throws:
ValidatorException - if the string cannot be converted into an object, or the object is not valid (due to other constraints).

renderValidatorContribution

void renderValidatorContribution(IFormComponent field,
                                 IMarkupWriter writer,
                                 IRequestCycle cycle)
Invoked by the field after it finishes rendering its tag (but before the tag is closed) to allow the validator to provide a contribution to the rendering process. Validators typically generated client-side JavaScript to peform validation.

Since:
2.2