<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 11, 2013 at 9:47 AM, Matt Benson <span dir="ltr"><<a href="mailto:mbenson@apache.org" target="_blank">mbenson@apache.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Gunnar,<br></div> I kind of like the idea of being able to use a single constraint definition type for either purpose, in that it avoids forcing users through semantic obstacles in expressing some basic concept. I'm less enthralled with another "magic" annotation element name, but I don't have a better idea at the moment either. I'm disagree with the idea that the default 'validationAppliesTo' value should be </div>
</blockquote><div><br></div><div>s/I'm disagree/I disagree/ :P<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">ANNOTATED_ELEMENT; I personally would rather see a default such as IMPLICIT whose presence requires that only one of @Constraint or @CrossParameterConstraint be present on the annotation type.<br>
<br>Matt<br></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Fri, Jan 11, 2013 at 9:22 AM, Gunnar Morling <span dir="ltr"><<a href="mailto:gunnar@hibernate.org" target="_blank">gunnar@hibernate.org</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Anyone with thoughts/feedback on this?<div><br></div><div>Thanks,</div>
<div><br></div><div>--Gunnar</div>
<div><div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/1/7 Gunnar Morling <span dir="ltr"><<a href="mailto:gunnar@hibernate.org" target="_blank">gunnar@hibernate.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>As per the latest spec draft, a constraint must be either a cross-parameter *or* a generic constraint, but not both at the same time, as otherwise it would be ambiguous whether a constraint on a method refers to the method parameters or return value.</div>
<div><br></div><div>Most of the time this does not really pose a limitation, but some constraints actually might be both, cross-parameter *and* generic, depending on the specific context. Examples are @ScriptAssert in Hibernate Validator or generic constraints such as this:</div>
<br>@EqualPasswords<br>public void register(String userName, String password, String confirmedPassword) {<br>}<br><br>@EqualPasswords<br>public class ResetPasswordRequest {<div> String userName;<br> String password;<br>
String confirmedPassword;<br>}<div><br></div><div>Based on a recent BVAL issue [1], I'm proposing to introduce a special constraint annotation attribute, "validationAppliesTo", allowing to specify the required behavior at the usage site:</div>
<div><br></div><div>@EqualPasswords(validationAppliesTo=PARAMETERS)<br>public void register(String username, String password, String confirmPassword) {<br>}<br><div><br></div><div>@EqualPasswords(validationAppliesTo=ANNOTATED_ELEMENT)<br>
public class ResetPasswordRequest {<br> String password;<br> String confirmedPassword;<br>}<br></div><div><br></div>
<div>The following rules would apply:</div><div><br></div><div>* If a constraint is annotated with @Constraint and @CrossParameterConstraint, it must define a member "validationAppliesTo". The default value should be ANNOTATED_ELEMENT.</div>
<div>* If a constraint is annotated with only one of @Constraint/@CrossParameterConstraint, defining a "validationAppliesTo" member doesn't have any special effect</div><div>* Specifying validationAppliesTo=PARAMETERS anywhere except a method causes ConstraintDeclarationException</div>
<div><br></div><div>Any thoughts?</div><div><br></div><div>--Gunnar</div>
<div><br></div><div>[1] <a href="https://hibernate.onjira.com/browse/BVAL-340" target="_blank">https://hibernate.onjira.com/browse/BVAL-340</a><br></div></div><div><br></div></div></div>
</blockquote></div><br></div></div></div></div>
<br></div></div>_______________________________________________<br>
beanvalidation-dev mailing list<br>
<a href="mailto:beanvalidation-dev@lists.jboss.org" target="_blank">beanvalidation-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/beanvalidation-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div>