Hello Umesh, You should be able to do what you want by composing your two constraints into a new "composite constraint." This is detailed in section 2.3 of Bean Validation spec 1.0 . You can simply declare these constraints on a new annotation that is itself annotated with @Constraint and @ReportAsSingleViolation . The main caveat is that you won't get individual error messages for these.
HTH, Matt On Fri, Oct 11, 2013 at 5:56 AM, Umesh Awasthi <[email protected]>wrote: > I am wondering about way to enable short circuiting on constraint defined > at field levels.Say i have a field > > *Code:* > private Integer phoneNumber; > and i have following validations on phoneNumber > *Code:* > @Digits(message="not.number") > @SecondValidation(value=10,message="my message") > private Integer phoneNumber; > > > In case i added alphanumeric value less than, i am getting both errors > > 1. Field should be number. > 2. Second Message will also be displayed > > Is there any way to tell BV API to not go for other validation if first > one failed (Short circuiting). In short i want to display only first error > if it failed and ignoring any other validation defined on that field / > property > > Is this feasible? > > - > With Regards > Umesh Awasthi > http://www.travellingrants.com/ > > >
