Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 88161 invoked from network); 8 Apr 2004 16:57:02 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 8 Apr 2004 16:57:02 -0000 Received: (qmail 47911 invoked by uid 500); 8 Apr 2004 16:56:48 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 47896 invoked by uid 500); 8 Apr 2004 16:56:48 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 47868 invoked from network); 8 Apr 2004 16:56:47 -0000 Received: from unknown (HELO helios.nfldinet.com) (65.121.5.4) by daedalus.apache.org with SMTP; 8 Apr 2004 16:56:47 -0000 Received: from integral7.com (unknown [209.98.197.83]) by helios.nfldinet.com (Postfix) with ESMTP id A47551B29B for ; Thu, 8 Apr 2004 11:53:53 -0500 (CDT) Message-ID: <40758451.2080507@integral7.com> Date: Thu, 08 Apr 2004 11:56:49 -0500 From: Kevin Kokal User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040124 X-Accept-Language: en-us, en MIME-Version: 1.0 To: commons-user@jakarta.apache.org Subject: [validator] Validating nested beans? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I'm using commons-validator to validate beans (not forms). In reading the "TODO" list for the project, it sounds like this is the direction the project is heading. One consideration, though, is that beans tend to have other beans nested within themselves, whereas forms just have fields. Has anyone had any success getting nested validations to work? A simple scenario may illustrate my point: Classes A, B, and C are all beans. Classes A and B both contain C, and both have getC() methods. I want to set up validation rules for class C, and I want those validations run whenever I validate A and B, too. One solution is to use the dot-notation in the property name:
<...other "A" validations...>
<...other "B" validations...> But this doesn't nicely lend itself to code reuse, because I have to repeat my "C" validations everywhere. I'm thinking that something like this may be better:
<...other "A" validations...>
<...other "B" validations...>
This is obviously a longer-term solution, requiring changes to the commons-validator core. Has anyone instead tried doing something similar using a validator method? --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org