Hi,
This is the first of a series of threads about the open questions regarding
value extraction [1]. We hope having a separate thread per question will
help having a more structured and easy to follow discussion.
Summary of the issue
================
ConstraintsApplyTo only allows one behavior per annotated element. Should
it be per constraint? E.g. for @NotNull @Email StringProperty email it may
be desirable to apply @NotNull to the wrapper but @Email to the wrapped
value. That’s not possible currently.
Summary of the discussions going on
============================
Matt proposed something like:
@ConstraintsApplyTo(target=WRAPPED_VALUE, constraintTypes=Size.class)
@Size(3)
List<String> nicknames;
As noted by Emmanuel, it does not solve the issue when you want 2 @Size
constraints, one for the List and the other for the enclosed String.
Emmanuel proposed to use groups to solve this issue:
"
But it makes me think that we sorta addresssed a similar class of problem
with groups.
I haven’t explored at all but could we something similar by subverting
groups. Let’s define two special groups: OnContainer OnWrappedValue
@Min(value3, groups=OnWrappedValue.class)
List<String> nicknames;
"
[1]
http://beanvalidation.org/latest-draft/spec/#_open_questions