[Stripes-users] Bean Validation

Subject:   [Stripes-users] Bean Validation (find more)
Date:   Nov 18, 2005 11:48

Return-Path: <hidden>
Received: from [] (ip68-106-242-188.ph.ph.cox.net [])
 (authenticated bits=0)
 by webserver.mongus.net (8.12.10/8.12.10) with ESMTP id jAIGkoAB002157
 for <hidden>; Fri, 18 Nov 2005 09:46:50 -0700
Message-ID: <hidden>
Date: Fri, 18 Nov 2005 09:48:35 -0700
From: Aaron Porter <hidden>
Reply-To: hidden
Sender: hidden
To: hidden
Subject: [Stripes-users] Bean Validation
Errors-To: hidden
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Original-To: hidden
Delivered-To: hidden
User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051105)
X-Accept-Language: en-us, en
X-Spam-Score: 1.0 (+)
X-Spam-Report: Spam Filtering performed by sourceforge.net.
 See http://spamassassin.org/tag/ for more details.
 Report problems to http://sf.net/tracker/?func=add&group_id=1&atid=200001
 1.0 FORGED_RCVD_HELO       Received: contains a forged HELO
X-BeenThere: hidden
X-Mailman-Version: 2.0.9-sf.net
Precedence: bulk
List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/stripes-users&gt;,
List-Id: A list for dicussing building applications with Stripes. <stripes-users.lists.sourceforge.net>
List-Post: <mailto:hidden>
List-Help: <mailto:hidden?subject=help>
List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/stripes-users&gt;,
List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum=stripes-users>

Hi everybody!
While I was working on my own implementation of a bean validation
framework using annotations I came across this thread in your archives:
and it gave me some ideas.

I've implemented several of the suggestions in the thread and put
together an LGPL'd package for bean validation using annotations. I
didn't make a pretty web site for it yet but the javadoc's are fairly

The package will make use of Hibernate validation annotations if they
exist but it doesn't require any third-party jars to function. It has
its own annotations that you can use as well as write your own
validation annotations. You can also extend it with translators for
other third-party validation annotations.

It's very easy to add validation to your beans. Here's a complete example:

import com.mongus.beans.validation.MaxLength;
import static com.mongus.beans.validation.BeanValidator.validate;

class MyBean
    public void setName(final String name)
        this.name = name;

It is designed to perform validation before you store anything to
prevent invalid data from making it into your bean. Don't forget to add
the validate call or it won't do anything! :-)

Each annotation has it's own error message that will be thrown in a
ValidationException. ValidationException extends
IllegalArgumentException so it doesn't need to be declared in a throws
statement. If you add an ErrorMessage annotation it will override any
messages from specific annotations.

The javadoc is available here:

Complete package with the source, docs and mongus-validation.jar is here:

Or if you don't want the source the mongus-validation.jar weighs in
under 23K:

This package is beta software. Criticism and/or suggestions gladly
accepted. :-)

Aaron Porter

This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
Stripes-users mailing list