Here is the validator node that is in the Note that in the example, we are requiring the user to enter an email address and then validating the email address the user entered.
To enable the user to edit his information that is stored in the Person object, we have this form: When the user submits the form, we want to validate his entries into the form fields.To validate a user’s form field entries you can use a separate XML file that contains your validation rules.The type attribute specifies which validator you want the Struts 2 framework to use (see Validation ).The param name=”fieldname” node is used to tell the framework which form field entry to apply the rule to.The example code for this tutorial, form-xml-validation, is available for checkout at struts-examples In this tutorial we’ll cover how to validate a user’s input in form fields using Struts 2’s XML validation methodology.
In the Form Validation tutorial we discussed validating a user’s input using the validate method in the Action class.
See for the form fields and their name value (review Struts 2 Form Tags if you’re not familiar with how to use Struts 2 form tags).
The message node is used to tell the framework what message to display if the validation fails.
Using a separate XML validation file gives you the ability to use validators built-in to the Struts 2 framework.
The Struts 2 user mailing list is an excellent place to get help.
Edit: As Dario mentions, this is not going to work for the Regular Expression Validator, as it does not support casing options.