commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amit (JIRA)" <>
Subject [jira] Commented: (VALIDATOR-170) [validator] Validating Arrays of simple Objects
Date Fri, 19 May 2006 04:34:31 GMT
    [ ] 

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 ( == null || == 0) {
                this.key = 
                        this.indexedListProperty + TOKEN_INDEXED;
            } else {
                this.key = 
                        this.indexedListProperty + TOKEN_INDEXED + "." +;

        } else {
            this.key =;

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

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

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

> [validator] Validating Arrays of simple Objects
> -----------------------------------------------
>          Key: VALIDATOR-170
>          URL:
>      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:
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message