<div dir="ltr"><div><div><div>Hi,<br><br></div>I don&#39;t think relying on groups is such a good idea. It&#39;s already a complicated area and adding some magic groups won&#39;t help.<br><br></div>Is there something preventing us from doing something like:<br>@Size(3, applyTo = ANNOTATED_ELEMENT)<br></div>@Size(10, applyTo = WRAPPED_VALUE)<br><div>
ListOfStrings nicknames;<br><br></div><div>ANNOTATED_ELEMENT would be the default and would mean apply the constraint to the currently annotated element.<br><br></div><div>So List&lt;@Size(10) String&gt; would mean apply the constraint to the annotated element so to the String.<br><br></div><div>List&lt;@Size(10, applyTo = WRAPPED_VALUE) Optional&lt;String&gt;&gt; would apply the constraint to the String contained in the Optional.<br><br></div><div>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.<br><br>-- <br></div><div>Guillaume<br></div></div>