Class FieldValidator
java.lang.Object
fc.web.forms.FieldValidator
Represents a form field validator. Various subclasses
implement concrete code (via
would verify that the
specified HTML form element of type "text" has the specified
length.
validate(FormData, HttpServletRequest)
) for various
validation strategies. Subclasses are typically specific to
both the field type and the type of validation. So for
example, the
invalid reference
ValidatorText
Field level validators differ from FormValidator
because validation is at the field (per field) level and is
independent of other fields in the form.
Note: Validator objects have state and a particular instance of a validator should only be assigned to one form field. To ensure this, validators take a field reference in their constructors and automatically add themselves to the specified field at construction time. During validation, validators are sequentially called in the order they were added (which implies in the order they were constructed).
Thread safety: None of the validation classes (like all other form-related classes) are thread safe. Synchronization must be done at a higher level, typically the session level.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
FieldValidator
Creates a new validator.- Parameters:
field
- the field to validate. This validator is added to the field automatically. Subclasses can later retrieve the field for validation.errorMessage
- the error message associated with invalid data SeegetErrorMessage()
-
-
Method Details
-
validate
-
getErrorMessage
-
getField
-