{@link Pattern} constraint validator implementation.
Note this implementation uses {@link RegExp} which differs from{@link java.util.regex.Pattern}.
Component
by matching the component's value against a regular expression pattern. A PatternValidator
can be constructed with either a Java regular expression (compiled or not) or a MetaPattern
. If the pattern matches against the value of the Component
it is attached to when validate
is called by the framework, then that input value is considered valid. If the pattern does not match, the errorMessage
method will be called. For example, to restrict a field to only digits, you might add a PatternValidator
constructed with the pattern "\d+". Another way to do the same thing would be to construct the PatternValidator
passing in MetaPattern.DIGITS
. The advantages of using MetaPattern
over straight Java regular expressions are that the patterns are easier to construct and easier to combine into complex patterns. They are also more readable and more reusable. See {@link org.apache.wicket.util.parse.metapattern.MetaPattern MetaPattern} fordetails.
The error message will be generated with the key "PatternValidator" and the message keys that can be used are:
Component
that failedComponent
- either comes from FormComponent.labelModel
or resource key [form-id].[form-component-id] in that order
|
|