|Apache Struts 2 Documentation > Home > FAQs > Cookbook > How to validate field formats, such as a phone number|
Validating the format of String fields for patterns (such as a phone number) is easy with StringRegexValidator (named "regex" in the default validator configuration).
Simply add the validator the field in question, and supply a regular expression to match it against.
If your expression tests against alpha characters, you may be interested in the "caseSensitive" parameter of with Validator as well. It defaults to "true".