Not all of the indexedListProperty collection elements are validated
--------------------------------------------------------------------
Key: VALIDATOR-245
URL: https://issues.apache.org/jira/browse/VALIDATOR-245
Project: Commons Validator
Issue Type: Improvement
Components: Framework
Affects Versions: 1.3.1 Release, 1.3.0 Release
Reporter: Edmund Ward
Priority: Minor
When the Field class method "validate(Map params, Map actions)" validates an
indexedListProperty it will return as soon as it finds an element in the
collection that fails validation. If other fields in the collection are invalid
too the user will only find out once they have corrected the first invalid
field. If the method were to validate all the fields in the collection (which
it will do anyway when all the elements are valid) the user would find all the
invalid fields the first time the bean is validated.
My proposed modification involves simply commenting out a couple of lines in
the Field class method "validate(Map params, Map actions)"
eg.
public ValidatorResults validate(Map params, Map actions)
throws ValidatorException {
if (this.getDepends() == null) {
return new ValidatorResults();
}
ValidatorResults allResults = new ValidatorResults();
Object bean = params.get(Validator.BEAN_PARAM);
int numberOfFieldsToValidate =
this.isIndexed() ? this.getIndexedPropertySize(bean) : 1;
for (int fieldNumber = 0; fieldNumber < numberOfFieldsToValidate;
fieldNumber++) {
Iterator dependencies = this.dependencyList.iterator();
ValidatorResults results = new ValidatorResults();
while (dependencies.hasNext()) {
String depend = (String) dependencies.next();
ValidatorAction action = (ValidatorAction) actions.get(depend);
if (action == null) {
this.handleMissingAction(depend);
}
boolean good =
validateForRule(action, results, actions, params, fieldNumber);
if (!good) {
allResults.merge(results);
//return allResults;
}
}
//allResults.merge(results);
}
return allResults;
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.