JSR 303 - Bean Validation

July 11, 2006 on 2:02 pm | In Technical stuff |

JSR 303 seeks to define a meta-data model and API for JavaBean validation. “This API is seen as a general extension to the JavaBeans object model, and as such is expected to be used as a core component in other specifications, such as JSF, JPA, and Bean Binding.”

A standardized validation API would be a great addition to the JDK. I’ve used a couple including Commons Validator and XWork’s bundled validation framework. These frameworks make life easier. However, like most things, there are no standards.

XWork’s implementation provides the ability to traverse the inheritance tree. It also allows for validation based on the context (method call). It comes with a number of validators, including stringlength, required, date. Validation can take place at field or non-field level. Fairly easy to use; I’ve only had issues when developing validation along with type-conversion for non-trivial objects. However, that is specific to web-based situations.

If the JSR will be based on XWork’s implementation, my major concern is the definition of a context. The previous definition of an aliasname does not exist in non-XWork specific implementations. Aliasname’s were simply the method name of an Action. This worked since Action execution methods were no-arg by convention. This concept will have to provide validation on method calls with arguments. By the nature of annotations, this will not be an issue. However, I am curious to see the XML-based solution. Last of all, I look forward to the ability to conditionally exclude validation based on the current context.

4 Comments »

RSS feed for comments on this post. TrackBack URI

  1. […] July bam01:05 pmAdd comment Looks like Jason Carreira has stepped up to the plate to try and consolidate the validation frameworks we have in Java. I’m sure it was a joint effort among many, but Jason’s name is the only one I see on the JSR. I applaud this effort - it’s definitely needed. I’ve used Commons Validator, the XWork Validation Framework as well as Hibernate’s Validator. While Commons and XWork work, the ability to annotate a class and validate it anywhere/anyhow is pretty cool. I reviewed an article a couple months ago that hooked Hibernate Validator into Spring MVC and Prototype for client-side validation. There’s a lot of good stuff in this space - let’s hope this JSR creates something even better. More than anything, let’s hope it doesn’t brush off client-side validation like JSF did. In an ideal world, the RIFE, Spring MVC, Stripes, Struts, Tapestry and Wicket developers will all participate and allow JSR-303’s result to be used as their framework’s validation engine. I think it’s a given that this will be usable with JSF. […]

    Pingback by Validation Framework Consolidation - Web 2.0 Squared Magazine — July 12, 2006 #

  2. […] A Validation Framework Consolidation JSR was started last year. Like others, I appreciate the initiative, but given that there’s not much activity around this JSR, are we going to see some consolidation in this area anytime soon ? […]

    Pingback by Sami Dalouche » Validation Framework Consolidation : where are we ? — June 3, 2007 #

  3. My only issue is that they are going towards the route to integrate and standardize validation with Web Beans (JBOSS Seam replica ), This is needless to say annoyingly unecessary. Seam is a great work around for JSF, but i hate to say this; it simply doesn’t add up.

    And another question that pops up with me is; that if we have something like JSR 305 which attempts to standardize @Annotations for tools to detect ‘possible’ null errors / assignments etc (or validation if i can be a little bold here) at compile time (irrespective of how tools implement such a spec), How will they standardize this spec with the above one … like if i write @NotNull (from above JSR) should it be interpreted differently from the ones spec’d out in this ?

    (Only being concerned about syntax and how they would handle such a complexity internally can prove to be naive, imho, imagine a situation where you have two @NotNull to mean differently) …

    Regards
    Vyas, Anirudh
    http://www.anirudhvyas.com
    http://www.anirudhvyas.org

    Comment by Anirudh Vyas — March 20, 2008 #

  4. […] in ‘06, I wrote about JSR 303, which aims to bring Bean Validation to the JDK. Well to be specific, it defines a meta-data model […]

    Pingback by that’s great… » JSR 303… 2 years later — March 26, 2008 #

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds. Valid XHTML and CSS. ^Top^