Save This Page
Home » tapestry-src-5.0.19 » org.apache.tapestry5 » [javadoc | source]
org.apache.tapestry5
public interface: Validator [javadoc | source]

All Known Implementing Classes:
    Max, MinLength, Required, MaxLength, Regexp, AbstractValidator, Email, Min

Used by a Field to enforce a constraint related to a form submission. Validators themselves are stateless singletons.

Validators are usually encapsulated inside a FieldValidator .

Method from org.apache.tapestry5.Validator Summary:
getConstraintType,   getMessageKey,   getValueType,   isRequired,   render,   validate
Method from org.apache.tapestry5.Validator Detail:
 public Class<C> getConstraintType()
    Returns the type of constraint value used with this validator. Constraint values are used to parameterize a validator, for example a "maxLength" validator will have a constraint value of type int (the maximum length allowed). For constraints that do not have a constraint value, this method returns null.
 public String getMessageKey()
 public Class<T> getValueType()
 public boolean isRequired()
    Returns true if the validator should be invoked for null or blank (empty string) values. This is generally false, but is true for validators that enforce that a non-blank value is required. This is the basis of the org.apache.tapestry5.Field#isRequired() property.
 public  void render(Field field,
    C constraintValue,
    MessageFormatter formatter,
    MarkupWriter writer,
    FormSupport formSupport)
 public  void validate(Field field,
    C constraintValue,
    MessageFormatter formatter,
    T value) throws ValidationException
    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). If and only if the value is approved by all Validators is the value applied by the field.