Uploaded image for project: 'Hibernate Validator'
  1. HV-980

Store violated element of a java.util.Set in Path

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects versions: 5.2.0.Beta1
    • Fix versions: 5.2.0.CR1
    • Components: None
    • Labels:
      None
    • Last commented by a user?:
      true
    • Sprint:

      Description

      When a bean property of type java.util.Set is annotated with @Valid (cascade validation), and an element of that Set is violated, the resulting Path of the ConstraintViolation does contain no information which element of the Set is violated. Unfortunately, the validation spec does not describe how the Path should be build when traversing a java.util.Set. However, using a Set is the most natural many-association type when it comes to domain modeling.

      Violated elements of Lists and arrays can be identified by their index, violated elements in a Map can be identified by the key. The only way to reliably identify the violated element of a Set is the element itself. Therefore the violated element has to be stored in the Path.

      Since the spec is very unclear what to do with Set elements, I suggest to store the violated element as Node.key in the Path. This would make the API changes minimal. It makes even more sense, since a Set can be considered as special kind Map, where each element is mapped to itself.

        Attachments

          Issue links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: