We're updating the issue view to help you get more done. 

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

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.

Environment

None

Status

Assignee

Gunnar Morling

Reporter

Felix Feisst

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Fix versions

Affects versions

5.2.0.Beta1

Priority

Major