Return-Path: X-Original-To: apmail-bval-user-archive@www.apache.org Delivered-To: apmail-bval-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 770F110CE7 for ; Sat, 12 Oct 2013 14:28:05 +0000 (UTC) Received: (qmail 68758 invoked by uid 500); 12 Oct 2013 14:28:04 -0000 Delivered-To: apmail-bval-user-archive@bval.apache.org Received: (qmail 68704 invoked by uid 500); 12 Oct 2013 14:28:01 -0000 Mailing-List: contact user-help@bval.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@bval.apache.org Delivered-To: mailing list user@bval.apache.org Received: (qmail 68691 invoked by uid 99); 12 Oct 2013 14:27:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Oct 2013 14:27:59 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of gudnabrsam@gmail.com designates 74.125.83.43 as permitted sender) Received: from [74.125.83.43] (HELO mail-ee0-f43.google.com) (74.125.83.43) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Oct 2013 14:27:54 +0000 Received: by mail-ee0-f43.google.com with SMTP id e52so2478173eek.30 for ; Sat, 12 Oct 2013 07:27:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=rN5lcjSsVsdG3jrXMVRIROviAHI7UTsvHjr/gBFf8DI=; b=p3YD59dMmSXn3gcdax8G68tNrWIMamsLultADyjJ2dtcvosJMZ1746z65ES48OdT8o 4yS5HzqNf8MOs/YSQflmolbU2AY0uuYhQtE20uiiB7lGb/NUh7yov2uwefvRGvvLXJFE xRRR5p8et0rUiR4XjJ4KnJNtkRYRq0ElbNfZWFuGs5XCyBgb3hDc4l7fiTGcyXbO7ub4 9StjEYBYak/ExwfEwEm6hleUarKm9H4sAgICMdkbMmsL/qVL8YC98LY9A5v/yA6rgIVn Xa6A0fm74+NNciwNk+eRvrLfvRqGcytaVQZk/37Zi+QY+XyTz6hLdGNcuDuurJ/ugUHW KAYg== MIME-Version: 1.0 X-Received: by 10.15.98.194 with SMTP id bj42mr38813310eeb.12.1381588053510; Sat, 12 Oct 2013 07:27:33 -0700 (PDT) Received: by 10.223.85.70 with HTTP; Sat, 12 Oct 2013 07:27:33 -0700 (PDT) Received: by 10.223.85.70 with HTTP; Sat, 12 Oct 2013 07:27:33 -0700 (PDT) Reply-To: gudnabrsam@gmail.com In-Reply-To: References: Date: Sat, 12 Oct 2013 09:27:33 -0500 Message-ID: Subject: Re: Short circuiting constraints on a field (Bean validation) From: Matt Benson To: Umesh Awasthi Cc: user@bval.apache.org Content-Type: multipart/alternative; boundary=089e0160cd8827ce3304e88c093a X-Virus-Checked: Checked by ClamAV on apache.org --089e0160cd8827ce3304e88c093a Content-Type: text/plain; charset=ISO-8859-1 If you like you could open a JIRA issue requesting this as a custom feature in Apache BVal, and/or implement and contribute it. Regards, Matt On Oct 12, 2013 7:10 AM, "Umesh Awasthi" wrote: > Thanks Matt, > > But we can not control underlying API ? > by control i mean by passing some kind of flag to BV and indicating that > we want this type of error reporting. > > Though solution you mentioned will work but that is user dependent as user > need to create those constraints. > Since working on a plugin so i can not do it myself. > > Anyways Thanks for your valuable inputs. > > Thanks > Umesh > > > > On Fri, Oct 11, 2013 at 8:27 PM, Matt Benson wrote: > >> 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 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/ >>> >>> >>> >> >> > > > -- > With Regards > Umesh Awasthi > http://www.travellingrants.com/ > > > --089e0160cd8827ce3304e88c093a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

If you like you could open a JIRA issue requesting this as a= custom feature in Apache BVal, and/or implement and contribute it.

Regards,
Matt

On Oct 12, 2013 7:10 AM, "Umesh Awasthi&quo= t; <umeshawasthi@gmail.com= > wrote:
Thanks Matt,

But we can not control und= erlying API ?
by control i mean by passing some kind of flag to B= V and indicating that we want this type of error reporting.

Though solution you mentioned will work but that is user depende= nt as user need to create those constraints.
Since working on a p= lugin so =A0i can not do it myself.

Anyways Thanks= for your valuable inputs.

Thanks
Umesh



On Fri, Oct 11, 201= 3 at 8:27 PM, Matt Benson <gudnabrsam@gmail.com> wrote:
Hello Umesh,
=A0 You sh= ould be able to do what you want by composing your two constraints into a n= ew "composite constraint." =A0This is detailed in section 2.3 of = Bean Validation spec 1.0 . =A0You can simply declare these constraints on a= new annotation that is itself annotated with @Constraint and @ReportAsSing= leViolation . =A0The main caveat is that you won't get individual error= messages for these.

HTH,
Matt


On Fri, Oct 11, 2013 at 5:5= 6 AM, Umesh Awasthi <umeshawasthi@gmail.com> 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 h= ave following validations on phoneNumber
Code:
=A0 =A0 =A0 =A0 @Digits(message=3D"not.nu= mber")
=A0 =A0@SecondValidation(value=3D10,message=3D"my messa= ge")
=A0 =A0 =A0 =A0 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<= br>
Is there any way to tell BV API to not go for other validation if first=20 one failed (Short circuiting). In short i want to display only first=20 error if it failed and ignoring any other validation defined on that=20 field / property

Is this feasible?

-
With R= egards
Umesh Awasthi
http://www.travellingrants.com/=

=A0 =A0=20




--
= With Regards
Umesh Awasthi
http://www.travellingrants.com/

=A0 =A0=20
--089e0160cd8827ce3304e88c093a--