commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amit (JIRA)" <j...@apache.org>
Subject [jira] Commented: (VALIDATOR-170) [validator] Validating Arrays of simple Objects
Date Fri, 19 May 2006 04:34:31 GMT
    [ http://issues.apache.org/jira/browse/VALIDATOR-170?page=comments#action_12412482 ] 

Amit commented on VALIDATOR-170:
--------------------------------

This can be achieved by making a small change in the generateKey method of Field class. The
method may be modified to look like.......

    public void generateKey() {
        if (this.isIndexed()) {
            if (this.property == null || this.property.length() == 0) {
                this.key = 
                        this.indexedListProperty + TOKEN_INDEXED;
            } else {
                this.key = 
                        this.indexedListProperty + TOKEN_INDEXED + "." + this.property;
            }

        } else {
            this.key = this.property;
        }
    }

The validation.xml configuration will then use following syntax to get this working....

<field property="" depends="integer" indexedListProperty="male">
    <arg0 key="person.male"/>
  </field>

Or the field can be made optional also..........

> [validator] Validating Arrays of simple Objects
> -----------------------------------------------
>
>          Key: VALIDATOR-170
>          URL: http://issues.apache.org/jira/browse/VALIDATOR-170
>      Project: Commons Validator
>         Type: Improvement

>     Versions: 1.3 Final
>  Environment: Operating System: Windows 2000
> Platform: PC
>     Reporter: William Ferguson
>     Priority: Minor

>
> The Validator needs the ability to validate an array of simple Objects such as 
> Strings. Ie it should be possible to define a bean like:
> class foo {
>   public String getBar();
>   public void setBar(String[] values);
> }
> and have the values of Bar validated.
> Currently (validator 1.1.3 as ships with Struts 1.2.8, and looks same in 1.1.4), 
> to validate an array of properties you need to specify
>   property='somePropertyName'
>   indexedListProperty='propertyAtWhichCollectionIsFound'
> This will iterate through the collection found at
> 'propertyAtWhichCollectionisFound',
> and will validate the 'somePropertyName' property on each element.
> But if it is a collection of Strings then there is no valid property name to define.
> Ie you don't seem to be able to validate a collection of Strings.
> To fix it, either 'property' needs to be optional (not recommended), or a new
> approach to indexed properties needs to be taken. Perhaps by allowing 'property' 
> to define where the array of values can be found as well as any property to 
> validate on the elements (using dot notation), and having the Validator 
> introspect the values at each step and determine whether ot needs to iterate
> over a collection. This would also solve some of the enhancements requests
> that have been made for the Validator.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message