[bv-dev] Value extraction open issue #2: per constraint ConstraintsApplyTo?

Guillaume Smet guillaume.smet at gmail.com
Fri Jan 13 06:12:00 EST 2017


Hi,

I don't think relying on groups is such a good idea. It's already a
complicated area and adding some magic groups won't help.

Is there something preventing us from doing something like:
@Size(3, applyTo = ANNOTATED_ELEMENT)
@Size(10, applyTo = WRAPPED_VALUE)
ListOfStrings nicknames;

ANNOTATED_ELEMENT would be the default and would mean apply the constraint
to the currently annotated element.

So List<@Size(10) String> would mean apply the constraint to the annotated
element so to the String.

List<@Size(10, applyTo = WRAPPED_VALUE) Optional<String>> would apply the
constraint to the String contained in the Optional.

The drawback I can see is that it adds a new reserved method to the
@Constraint annotations. To make the migration more smooth, we could make
it optional and test the returnType of the method before using the result.

-- 
Guillaume
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/beanvalidation-dev/attachments/20170113/8949c25c/attachment.html 


More information about the beanvalidation-dev mailing list