Description Summary Validation fields that do not appear in forms they are
associated with indicate that the validation logic is out of
date.
Extended Description It is easy for developers to forget to update validation logic when they make changes to an ActionForm class. One indication that validation logic is not being properly maintained is inconsistencies between the action form and the validation form.
Example 1 An action form with two fields. (Bad Code) Java public class DateRangeForm extends ValidatorForm { String startDate, endDate;
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
} This example shows an action form that has two fields, startDate and endDate. Example 2 A validation form with a third field. (Bad Code) XML <form name="DateRangeForm"> <field property="startDate"
depends="date">
<arg0 key="start.date"/>
</field>
<field property="endDate" depends="date">
<arg0 key="end.date"/>
</field>
<field property="scale"
depends="integer">
<arg0 key="range.scale"/>
</field>
</form> This example lists a validation form for the action form. The validation form lists a third field: scale. The presence of the third field suggests that DateRangeForm was modified without taking validation into account.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Page Last Updated:
October 29, 2009
|
|
CWE is a Software Assurance strategic initiative sponsored by the National Cyber Security Division of the U.S. Department of Homeland Security. This Web site is hosted by The MITRE Corporation. Contact cwe@mitre.org for more information. |
|||
