DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13528>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13528 Add "requiredif" rule Summary: Add "requiredif" rule Product: Struts Version: Nightly Build Platform: Other OS/Version: Other Status: NEW Severity: Enhancement Priority: Other Component: Validator Framework AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] This adds the requiredif rule to Struts (patch attached). Here's a summary of the functionality: It allows you to define logic like "only validate this field if field X is non- null and field Y equals "male". The syntax looks like this: If you have this in your struts-config.xml <form-bean name="dependentlistForm" type="com.benefit.association.struts.forms.ValidatorForm"> <form-property name="dependents" type="com.benefit.association.Dependent[]" initial="{'','','','','','','','','','',''}"/> <form-property name="insureDependents" type="java.lang.Boolean" initial="false"/> </form-bean> Where dependent is a bean that has properties lastName, firstName, dob, coverageType You can define a validation: <form name="dependentlistForm"> <field property="firstName" indexedListProperty="dependents" depends="requiredif"> <arg0 key="dependentlistForm.firstName.label"/> <var> <var-name>field[0]</var-name> <var-value>lastName</var-value> </var> <var> <var-name>field-indexed[0]</var-name> <var-value>true</var-value> </var> <var> <var-name>field-test[0]</var-name> <var-value>NOTNULL</var-value> </var> </field> <field property="dob" indexedListProperty="dependents" depends="requiredif,date"> <arg0 key="dependentlistForm.dob.label"/> <var> <var-name>field[0]</var-name> <var-value>lastName</var-value> </var> <var> <var-name>field-indexed[0]</var-name> <var-value>true</var-value> </var> <var> <var-name>field-test[0]</var-name> <var-value>NOTNULL</var-value></var> </field> <field property="coverageType" indexedListProperty="dependents" depends="requiredif"> <arg0 key="dependentlistForm.coverageType.label"/> <var> <var-name>field[0]</var-name> <var-value>lastName</var-value> </var> <var> <var-name>field-indexed[0]</var-name> <var-value>true</var-value> </var> <var> <var-name>field-test[0]</var-name> <var-value>NOTNULL</var-value> </var> <var> <var-name>field[1]</var-name> <var-value>insureDependents</var-value> </var> <var> <var-name>field-test[1]</var-name> <var-value>EQUAL</var-value> </var> <var> <var-name>field-value[1]</var-name> <var-value>true</var-value> </var> <var> <var-name>field-join</var-name> <var-value>AND</var-value> </var> </field> </form> Which is read as follows: The firstName field is only required if the lastName field is non-null. Since field-indexed is true, it means that lastName must be a property of the same indexed field as firstName. Same thing for dob, except that we validate for date if not blank. The coverageType is only required if the lastName for the same indexed bean is not null, and also if the non-indexed field insureDependents is true. You can have an arbitrary number of fields by using the [n] syntax, the only restriction is that they must all be AND or OR, you can't mix. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>