UI-Component Sets
Project Documentation

Summary

Tag name: <f:validateRegex>
Validator class: javax.faces.validator.RegexValidator
Tag class: org.apache.myfaces.taglib.core.ValidateRegexTag
validator id: javax.faces.RegularExpression

RegexValidator is a {@link javax.faces.validator.Validator} that checks the value of the corresponding component against specified pattern using Java regular expression syntax. The regular expression syntax accepted by the RegexValidator class is same as mentioned in class {@link java.util.regex.Pattern} in package java.util.regex.

The following algorithm is implemented:

  • If the passed value is null, exit immediately.
  • If the passed value is not a String, exit with a {@link #NOT_MATCHED_MESSAGE_ID} error message.
  • If no pattern has been set, or pattern resolves to null or an empty String, throw a {@link javax.faces.validator.ValidatorException} with a {@link #PATTERN_NOT_SET_MESSAGE_ID} message.
  • If pattern is not a valid regular expression, according to the rules as defined in class {@link java.util.regex.Pattern}, throw a {@link ValidatorException} with a (@link #MATCH_EXCEPTION_MESSAGE_ID} message.
  • If a pattern property has been configured on this {@link javax.faces.validator.Validator}, check the passed value against this pattern. If value does not match pattern throw a {@link ValidatorException} containing a {@link #NOT_MATCHED_MESSAGE_ID} message.

Attributes

Name Type Supports EL? Description
binding javax.faces.validator.RegexValidator Only EL A ValueExpression that evaluates to a RegexValidator.
disabled Boolean Yes
for String Yes
pattern String Yes Return the ValueExpression that yields the regular expression pattern when evaluated.