org.apache.tapestry.form.validator
Interface ValidatorFactory
- All Known Implementing Classes:
- ValidatorFactoryImpl
- public interface ValidatorFactory
Constructs Validator
instances from a specification. A
specification is a comma-seperated list of entries. Each entry is in one of the following forms:
- name
- name=value
- name[message]
- name=value[message]
- $name
Most validator classes are configurable: they have a property that matches their
name. For example, MinDate
(which is named "minDate"
has a minDate
property. A few validators are not configurable ("required" =>
Required
, for example).
Validators are expected to have a public no-args constructor. They are also expected to have a
message
property which is set from the value in brackets.
The message is either a literal string, or may be prefixed with a '%' character, to indicate
a localized key, resolved using the component's message catalog.
When the name is prefixed with a dollary sign, it indicates a reference to a bean
with the given name.
A full validator specification might be:
required,email[%email-format],minLength=20[Email addresses must be at least 20 characters long.]
- Since:
- 4.0
- Author:
- Howard Lewis Ship
constructValidatorList
public java.util.List constructValidatorList(IComponent component,
java.lang.String specification)
- Constructs a new (immutable) List of
Validator
, or returns a previously constructed
List.
- Parameters:
component
- the component for which the list is being createdspecification
- a string identifying which validators and their configuration
- Returns:
- List of
Validator
(possibly empty)