Managing Validators
The Validator functionality within the Struts framework is intended for validating the data of forms in a Web application.
The Validator functionality uses two xml
configuration files:
- The
validator-rules.xml
file defines the standard reusable validation routines that make the basis for configuring form-specific validations. The file is created when you enable Struts support and is supplied with a predefined set of commonly used validation rules such as Required, Minimum Length, Maximum length, Date Validation, Email Address validation and others.The file is closed for editing.
- In the
validation.xml
file, define the validations applied to a particular form bean.
While you edit validation.xml
, IntelliJ IDEA coordinates the code of the two files and provides you with coding assistance based on the routines defined in validator-rules.xml
.
To define the validations to apply to a form
- Open
validation.xml
. - To add a validation definition, add the
<form-validation>
tag manually. - Switch to the Struts Assistant tool window, tab Validator. A new node appears in the Structure Tree.
- Edit the attributes of the validation definition in the Properties Table.
Last modified: 24 July 2018