Uploaded image for project: 'Bean Validation'
  1. BVAL-226

Make clear whether the static or the runtime type should be considered when creating property paths in case of cascaded validations


    • Last commented by a user?:
    • Sprint:


      As of version 1.0 the specification does not clearly state, whether the static or the runtime type of an association should be considered when creating property paths in case of cascaded validations.

      Let there be the following type:

      class Foo {
         private Collection<Bar> bar1 = new ArrayList<Bar>();
         private List<Bar> bar2 = new ArrayList<Bar>();

      When validating an instance of Foo (which has invalid elements in bar1/bar2) with the RI, the resulting property path node for bar1 would be iterable but not indexable ("bar1[]"), while the property path node for bar2 would be iterable and indexable ("bar2[123]"). This is that way because the static type of bar1/bar2 (Collection vs. List) is considered by the RI when building the nodes, and not the runtime type (ArrayList in both cases).

      According to a post [1] on the Hibernate Validator forum Apache's JSR 303 implementation follows the runtime type approach. This seems reasonable to me, too (as for instance the constraints to validate are also determined based on the runtime type of references).

      The specification should make clear what the intended behavior is and provide a TCK test case.

      [1] related forum post: https://forum.hibernate.org/viewtopic.php?f=9&t=1010626
      [2] related discussion on hibernate-dev: http://lists.jboss.org/pipermail/hibernate-dev/2011-April/006357.html


          Issue links



              • Votes:
                1 Vote for this issue
                1 Start watching this issue


                • Created: