<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello,<div><br></div><div>Been lurking a while. &nbsp;I have also struggled to control ordering like Cemo. &nbsp;Unfortunately a&nbsp;global "short circuit" setting is not sufficient for my enterprise (a number of reasons, but this email is already long enough).</div><div><br></div><div>Here's my 1st suggestion. &nbsp;This would solve the use case of "prerequisite validations" (see&nbsp;<a href="http://relation.to/Bloggers/JSRBeanValidation11WhatToPutIn#comment22221">http://relation.to/Bloggers/JSRBeanValidation11WhatToPutIn#comment22221</a> for example), as well as most use cases of "cheap vs. expensive" provided you don't need different messages. &nbsp;Also, IMHO it is overdue:&nbsp;<u>not</u> short circuiting (as today) is totally redundant. &nbsp;Is there a reason this wasn't specified for BV 1.0?</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><b>"When @ReportAsSingleViolation is present, short circuit."</b></div></blockquote><div><br></div><div>so</div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div>@Size(5)</div><div>@Pattern("[0-9]{5}")</div><div>@Constraint(validatedBy=BusinessPostCodeValidator.class) <i>// expensive; query explodes if size &gt; DB column length</i></div><div>@ReportAsSingleViolation&nbsp;<i>// only query DB if @Size and @Pattern pass</i></div><div>public @interface PostCode {&nbsp;...</div><div>&nbsp; &nbsp; String message() default "not a valid postal code";</div><div>}</div></blockquote><div><br></div><div><br></div><div>If different messages are needed, then @GroupSequence works but as Cemo says is unwieldy, and furthermore in practice breaks when combined with group inheritance (which is very natural and useful). &nbsp;So...2nd suggestion:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><b>"Allow @GroupSequence to be combined with interface inheritance in the obvious way."</b></div></blockquote><div><br></div><div>(OK, "obvious" has a lot of nasty edge cases, but let me demonstrate why this would be a good change:)</div><div><br></div><div>Currently the following gives wacky and IMHO wrong results (test case available on request). &nbsp;A close reading of BV 1.0 spec shows @GroupSequence and inheritance are incompatible...but the interactions are not intuitive:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div>@GroupSequence({Name1.class, Name2.class, Name3.class})</div><div>interface Names {</div><div>&nbsp; &nbsp; interface Name1 {}</div><div>&nbsp; &nbsp; interface Name2 {}</div><div>&nbsp; &nbsp; interface Name3 {}</div><div>}</div><div><br></div><div><div>@GroupSequence({Surname1.class, Surname2.class, Surname3.class})</div></div><div><div>interface Surnames {</div><div>&nbsp; &nbsp; interface Surname1 {}</div><div>&nbsp; &nbsp; interface Surname2 {}</div><div>&nbsp; &nbsp; interface Surname3 {}</div><div>}</div></div><div><br></div><div>interface BusinessValidations extends Names, Surnames {}</div><div><br></div><div>// A<i>t least the client wouldn't have to see all the ugliness.</i></div><div><i>// Maintenance, extensibility improved...but the following doesn't work!</i></div><div><i>// Currently no warning/error; only discover failure by test cases.</i></div><div>validator.validate(account, BusinessValidations.class);</div></blockquote><div><br></div><div><br></div><div>From my perspective proposal #1 would get 80% of the way, and #2 would get the rest as well as solve some very wacky (buggy?) interactions I've observed in my year+ of using BV 1.0. &nbsp;[There are other, more subtle ways that @GroupSequence messes with inheritance -- even when used in unrelated groups passed to #validate(...) -- that I'd be happy to move to a different topic.]</div><div><br></div><div>Thanks for a great product!</div><div><br></div><div>Regards,</div><div><br></div><div><div><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div>Peter Davis</div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br><div><div>On 3-Jan-2012, at 13:12 , Gerhard Petracek wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div><div>hi,</div><div><br></div><div>actually we had a related discussion about it for bv v1.0.</div><div>(the topic was "sort-circuit" and one suggestion was to introduce e.g. ValidatorContext#failAtFirstViolation)</div>

<div><br></div><div>+1 for re-visiting this topic.</div><div><br></div><div>regards,</div><div>gerhard</div></div><div><br></div><div><br></div><div><br></div></div><div><div class="gmail_quote">2012/1/3 Cemo <span dir="ltr">&lt;<a href="mailto:cemalettin.koc@gmail.com">cemalettin.koc@gmail.com</a>&gt;</span><br>

<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; position: static; z-index: auto; ">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 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; word-wrap: normal; text-align: left; background-color: rgb(240, 240, 240); position: static; z-index: auto; ">
<span 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 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 style="background-color:inherit;color:rgb(145,0,145)">String</span> surname;

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

   <span style="background-color:inherit;color:rgb(0,0,145)">public</span> <span style="background-color:inherit;color:rgb(0,0,145)">interface</span> Surname1 {}
   <span style="background-color:inherit;color:rgb(0,0,145)">public</span> <span style="background-color:inherit;color:rgb(0,0,145)">interface</span> Surname2 {}
   <span style="background-color:inherit;color:rgb(0,0,145)">public</span> <span style="background-color:inherit;color:rgb(0,0,145)">interface</span> Surname3 {}
   @GroupSequence({Surname1.class, Surname2.class, Surname3.class})
   <span style="background-color:inherit;color:rgb(0,0,145)">public</span> <span 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 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;word-wrap:normal;text-align:left;background-color:rgb(240,240,240)">
<span 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 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 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>_______________________________________________<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" target="_blank">https://lists.jboss.org/mailman/listinfo/beanvalidation-dev</a><br>
<br></blockquote></div><br></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></body></html>