Base class for form component validators. This class is thread-safe and
therefore it is safe to share validators across sessions/threads.
Error messages can be registered on a component by calling one of the
error(FormComponent ...) overloads. The error message will be retrieved using
the Localizer for the form component. Normally, this localizer will find the
error message in a string resource bundle (properties file) associated with
the page in which this validator is contained. The key that is used to get
the message defaults to the pattern:
[form-name].[component-name].[validator-class]. For example:
MyForm.name.RequiredValidator=A name is required.
Error message string resources can contain optional property variable
interpolations from the component, such as:
editBook.name.LengthValidator='${input}' is too short a name.
Available variables for interpolation are:
${input} - The user's input
${name} - The name of the component
${label} - the label of the component - either comes from
FormComponent.labelModel or resource key [form-id].[form-component-id] in
that order
but specific validator subclasses may add more values.
Error messages can be registered on a component by calling one of the error(FormComponent ...) overloads. The error message will be retrieved using the Localizer for the form component. Normally, this localizer will find the error message in a string resource bundle (properties file) associated with the page in which this validator is contained. The key that is used to get the message defaults to the pattern:
[form-name].[component-name].[validator-class]. For example:MyForm.name.RequiredValidator=A name is required.
Error message string resources can contain optional property variable interpolations from the component, such as:
editBook.name.LengthValidator='${input}' is too short a name.
Available variables for interpolation are:
- ${input} - The user's input
- ${name} - The name of the component
- ${label} - the label of the component - either comes from
FormComponent.labelModel or resource key [form-id].[form-component-id] in
that order
but specific validator subclasses may add more values.