commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ed Cavalari" <>
Subject commons-validator indexed properties
Date Wed, 15 Mar 2006 13:30:10 GMT
   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);

                ValidatorAction action = (ValidatorAction) actions.get
                if (action == null) {

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


                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)
       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.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message