Uploaded image for project: 'Commons Validator'
  1. Commons Validator
  2. VALIDATOR-170

Validating Arrays of simple Objects

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Abandoned
    • 1.3.0 Release
    • 2.0
    • Framework
    • None
    • Operating System: Windows 2000
      Platform: PC

    • 32978

    Description

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            wjrf@optusnet.com.au William Ferguson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: