Hi,
   I would like to be able to run the validation on every item in a list and
I'm finding that as soon as one of the elements fails validation, the
validator stops and the remaining items in the list are not validated.  I
took a look at the source code and this is what I found.

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.getIndexedProperty(bean).length : 1;

        for (int fieldNumber = 0; fieldNumber < numberOfFieldsToValidate;
fieldNumber++) {

            Iterator dependencies = this.dependencyList.iterator();
            while (dependencies.hasNext()) {
                String depend = (String) dependencies.next();

                ValidatorAction action = (ValidatorAction) actions.get
(depend);
                if (action == null) {
                    this.handleMissingAction(depend);
                }

                ValidatorResults results = new ValidatorResults();
                boolean good =
                    validateForRule(action, results, actions, params,
fieldNumber);

                allResults.merge(results);

                if (!good) {
                    return allResults;
                }
            }
        }

        return allResults;
    }

This method of the Field class appears to be the culprit of my problem.  I
would like to suggest that the dtd and code be changed to allow for a flag
that allows all items in the list to be
processed,(processAllItems="true|false" default = false).  Then the test
if (!good) {
  return allResults;
 }

 could change to say,
 if (!good)
{
    if (processAllItems)
   {
       break;
    }
    else
    {
       return allResults;
   }
 }

I've changed the source to do the break and everything works as I would like
it to.  Unfortunately my shop won't allow me to make this change for our
project, but it you guys make the change and release I can use it.

Thanks,
Ed

Reply via email to