Examples of the validwhen validator.

struts-config-validwhen.xml   validation-validwhen.xml

Simple validwhen example The Last Name must be entered IF a First Name is present.

First Name Last Name  

Both Fields Example Either both the fields must be present OR both must be absent.

 

Numeric Compare Example Maximum value must be numeric and greater than the minimum.

Minimum Maximum  

Address Validation example If any one of the address fields is present then Address Line 1, City and State must be present. Address Line 2 is optional.

Address Line 1  
Address Line 2  
City  
Zip Code  


Tips on Using the validwhen Validator


Issues When (trying) to Use the validwhen Validator