<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I have not seen your proposal till now.<div><br><div><a href="https://hibernate.onjira.com/browse/BVAL-220?focusedCommentId=42681&amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-42681">https://hibernate.onjira.com/browse/BVAL-220?focusedCommentId=42681&amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-42681</a></div><div><br></div><div>This looks quite elegant and only require BVAL-259 to be solved.&nbsp;Peter's proposal makes it work for any type and any definition of "null".&nbsp;The only drawback is that's it's more subtle / cryptic than an explicit param or annotation.</div><div><br><div><div>On 4 janv. 2012, at 16:46, Peter Davis wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div bgcolor="#FFFFFF"><div>Can the proposal for special null/empty handling be generalized? &nbsp;I have two extra use cases,</div><div><br></div><div>- Concept of "empty" for objects, for example my enterprise often uses a "money" object (value+currency)</div>
<div>- Need to define "prerequisite" validations in general, for example check @NotNull+@Size before a DB query to avoid a query exception</div><div><br></div><div>Regards,</div><div>Peter Davis</div><div><br>On Jan 4, 2012, at 5:29, Emmanuel Bernard &lt;<a href="mailto:emmanuel@hibernate.org">emmanuel@hibernate.org</a>&gt; wrote:<br>
<br></div><div></div><blockquote type="cite"><div>Hi,<div>Let me try and summarize what you want to be sure we are on the same page:</div><div><br></div><div>- you want sometimes to return one and only one failure per property</div>
<div>- you want some constraints to be validated before others (to be the one displayed)</div><div><br></div><div>Besides not empty which should be simply ignored by your unique email constraint, do you have other use cases? I would rather exclude null / empty from the list of use cases because it's a fairly pathological case and we plan on addressing that via a different mechanism (namely a way to mark a constraint validator as being called only on non null / non empty values).</div>
<div><br></div><div>I've been trying to avoid numerical ordering (the fancy name is&nbsp;salience I believe) so far so I'd like to see concrete use cases that cannot be solved otherwise.</div><div><br></div><div>Having a per property shortcut and a global shortcut would be a nice a easy feature to add. We left it out of 1.0 but it almost made it through.</div>
<div><br></div><div>Likewise, we could fake salience by providing a special group</div><div><br></div><div>```</div><div>package javax.validation.groups;</div><div><br></div><div>@GroupSequence({Level1.class,&nbsp;Level2.class,&nbsp;Level3.class,&nbsp;Level4.class,&nbsp;Level5.class,&nbsp;Level6.class,&nbsp;Level7.class,&nbsp;Level8.class,&nbsp;Level9.class,&nbsp;Level10.class})</div>
<div>interface Order {</div><div>&nbsp; &nbsp; interface Level1 {}</div><div>&nbsp; &nbsp; interface Level2 {}</div><div>&nbsp; &nbsp; interface Level3 {}</div><div>&nbsp; &nbsp; ...</div><div>&nbsp; &nbsp; interface Level10 {}</div><div>}</div><div>```</div><div><br></div>
<div>Frankly I'd rather avoid it but that would work.</div><div><br><div><div>On 3 janv. 2012, at 21:33, Cemo wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi experts,<div><br></div><div>After reading your comments and mail list I realized that it will be better share our opinions here about our problems.</div>
<div><br></div><div>First, I would like to thanks all of you to provide such an&nbsp;elegant&nbsp;library and spec. After latest improvements at spring side, I am sure that bean validation will be defacto validation framework among java community.</div>


<div><br></div><div>The only problem We are facing is that ordered validations.</div><div><br></div><div>In a common sense validation such this can be feasible:&nbsp;</div><div><br></div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<pre class="code-java" style="margin-top:0px;margin-bottom:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;font-size:1.2em;line-height:1.3em;max-height:30em;overflow-x:auto;overflow-y:auto;word-wrap:normal;text-align:left;background-color:rgb(240,240,240)"><span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">public</span> class AccountBean {

   @CheapValidation(groups=Name1.class)
   @ExpensiveValidation(groups=Name2.class)
   @VeryExpensiveValidation(groups=Name3.class)
   <span class="code-object" style="background-color:inherit;color:rgb(145,0,145)">String</span> name;

   @CheapValidation(groups=Surname1.class)
   @ExpensiveValidation(groups=Surname2.class)
   @VeryExpensiveValidation(groups=Surname3.class)
   <span class="code-object" style="background-color:inherit;color:rgb(145,0,145)">String</span> surname;

   <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">public</span> <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">interface</span> Name1 {}
   <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">public</span> <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">interface</span> Name2 {}
   <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">public</span> <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">interface</span> Name3 {}
   @GroupSequence({Name1.class, Name2.class, Name3.class})
   <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">public</span> <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">interface</span> Name {}

   <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">public</span> <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">interface</span> Surname1 {}
   <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">public</span> <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">interface</span> Surname2 {}
   <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">public</span> <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">interface</span> Surname3 {}
   @GroupSequence({Surname1.class, Surname2.class, Surname3.class})
   <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">public</span> <span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">interface</span> Surname {}
}</pre></blockquote><div><br></div><div><br></div><div>There is&nbsp;two common usage for this. The first usage: some validations are expensive that should be runned if all validations pass. Another usage is for each field there should be one violation. For email, if it is empty, uniqueEmail constraint must not be checked. I hope that how much necessary it is for us you can imagine. Almost all fields has such restrictions. Ordering and&nbsp;shortcutting&nbsp;are crucial for us.</div>


<div><br></div><div>But just to provide validation order and shortcut GroupSequence is practically &nbsp;impossible to use at enterprice level. For each field again and again we are declaring interfaces. It is not only&nbsp;intuitive&nbsp;but also seems ugly. By the way what is came to my mind is for each constraint, declaring a order like this:</div>


<div><br></div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<pre class="code-java" style="margin-top:0px;margin-bottom:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;font-size:1.2em;line-height:1.3em;max-height:30em;overflow-x:auto;overflow-y:auto;word-wrap:normal;text-align:left;background-color:rgb(240,240,240)"><span class="code-keyword" style="background-color:inherit;color:rgb(0,0,145)">public</span> class AccountBean {

   @CheapValidation(order=0,groups=Name1.class)
   @ExpensiveValidation(order=1,groups=Name2.class)
   @VeryExpensiveValidation(order=2,groups=Name3.class)
   <span class="code-object" style="background-color:inherit;color:rgb(145,0,145)">String</span> name;

   @CheapValidation(order=0,groups=Surname1.class)
   @ExpensiveValidation(order=1,groups=Surname2.class)
   @VeryExpensiveValidation(order=2,groups=Surname3.class)
   <span class="code-object" style="background-color:inherit;color:rgb(145,0,145)">String</span> surname;
}</pre></blockquote><div><br></div><div>Default value for ordering might be same for all&nbsp;constraints.</div><div><br></div><div>Please help community. :)&nbsp;</div><div><br></div><div>Thanks &amp; happy new year &nbsp;</div>
_______________________________________________<br>beanvalidation-dev mailing list<br><a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev">https://lists.jboss.org/mailman/listinfo/beanvalidation-dev</a><br>
</blockquote></div><br></div></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>beanvalidation-dev mailing list</span><br><span><a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.jboss.org</a></span><br>
<span><a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev">https://lists.jboss.org/mailman/listinfo/beanvalidation-dev</a></span><br></div></blockquote></div>
_______________________________________________<br>beanvalidation-dev mailing list<br><a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/beanvalidation-dev<br></blockquote></div><br></div></div></body></html>