org.apache.tapestry5.validator

## Class AbstractValidator<C,T>

- java.lang.Object
- - org.apache.tapestry5.validator.AbstractValidator<C,T>

- All Implemented Interfaces:
    Validator<C,T>
  Direct Known Subclasses:
    Checked, Email, Max, MaxLength, Min, MinLength, None, Regexp, Required, Unchecked

      public abstract class AbstractValidator<C,T>
      extends java.lang.Object
      implements Validator<C,T>

  Base class for constructing a `Validator`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected JavaScriptSupport` | `javaScriptSupport`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractValidator(java.lang.Class<C> constraintType, java.lang.Class<T> valueType, java.lang.String messageKey, JavaScriptSupport javaScriptSupport)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Class<C>` | `getConstraintType()` Returns the type of constraint value used with this validator.
    `java.lang.String` | `getMessageKey()` Returns the message key, within the validation messages, normally used by this validator.
    `java.lang.Class<T>` | `getValueType()` Returns the value type associated with this validator.
    `boolean` | `isRequired()` Return false, which is correct for the vast majority of validators.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.tapestry5.Validator

      `render, validate`

- - ### Field Detail

    - #### javaScriptSupport

          protected final JavaScriptSupport javaScriptSupport

  - ### Constructor Detail

    - #### AbstractValidator

          protected AbstractValidator(java.lang.Class<C> constraintType,
                                      java.lang.Class<T> valueType,
                                      java.lang.String messageKey,
                                      JavaScriptSupport javaScriptSupport)

  - ### Method Detail

    - #### getConstraintType

          public final java.lang.Class<C> getConstraintType()

      Description copied from interface: `Validator`
      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.
      Specified by:
        `getConstraintType` in interface `Validator<C,T>`

    - #### getValueType

          public final java.lang.Class<T> getValueType()

      Description copied from interface: `Validator`
      Returns the value type associated with this validator. `Validator.validate(Field, Object, MessageFormatter, Object)` will only be invoked when the value is assignable to the validator's value type.
      Specified by:
        `getValueType` in interface `Validator<C,T>`

    - #### getMessageKey

          public final java.lang.String getMessageKey()

      Description copied from interface: `Validator`
      Returns the message key, within the validation messages, normally used by this validator. This is used to provide the `MessageFormatter` passed to `Validator.validate(Field, Object, MessageFormatter, Object)` (unless overridden).
      Specified by:
        `getMessageKey` in interface `Validator<C,T>`
      Returns:
        a message key

    - #### isRequired

          public boolean isRequired()

      Return false, which is correct for the vast majority of validators. `Required` overrides this to true.F
      Specified by:
        `isRequired` in interface `Validator<C,T>`

${project.version} - Copyright © 2003-2015 The Apache Software Foundation.