| < Day Day Up > |
|
Working with e-mail and credit cards is quite easy because neither rule takes arguments. Both routines are converted from working routines that were used by JavaScript and Perl developers, respectively. Ted Husted translated these routines to Java and added them to the Validator Framework. Here's how you use them in the field declaration in validation.xml:
<field property="email" depends="required,email"> <arg0 key="inputForm.email" /> </field> <field property="creditCard" depends="creditCard"> <arg0 key="inputForm.creditCard" /> </field>
This code maps the email rule to the email property and the creditCard rule to the creditCard field in our ActionForm. We added the creditCard and email properties in the Action and the corresponding labels in the resource bundle.
You can find the implementation for all the rules that ship with the Validator Framework in org.apache.struts.validator.FieldChecks and org.apache.commons.validator.GenericValidator.
| < Day Day Up > |
|