I’ve made a little JSR303 annotation library

I’ve been playing with Hibernate Validator 4.0 lately, it’s an implementaion of JSR 303 Bean Validation – basically the ability to annotate validations for your beans. Great in Hibernate as you’ll know if you’ve ever done it because you’re object describe the constraints and Hibernate enforces them for you.

JSR 303 builds on it by codifying the annotated validation framework into a standard you should be able to use from front to back and everywhere in between maintaining your rules for what is and is not valid. Of course that’s the pot of gold at the end of the rainbow, it’s far messier living on the bleeding edge before the standards have been officially released.

I’ve released a small very early project that builds on some of the stuff I’ve done using the Hibernate annotaions with Springframework in the past. Basically, wrap a Spring validator around the Hibernate one – or in this case around a generic javax.annotations validator.

I’ve also added a few new constraints that I need. NotEmpty validates that a field must not be null and must not have a size of 0. Email validates email addresses and URL validates Urls. It’s an early release, but check it out here on GitHub if you’re interested. If you want to use it feel free if you want to make additions I’d love to accept them.

Reblog this post [with Zemanta]

No related posts.


About this entry

You’re currently reading “I’ve made a little JSR303 annotation library,” an entry on andrewmccall.com

Published:
7.7.09 / 9pm
Category:
random
Tags:

My Projects

Twitter


Comments

Jump to comment form | comments rss [?] | trackback uri [?]
  • John Hunsley
    Nice 1, I like small wrapper packages like this, small steps!
  • Hey John, It's a bit rough around the edges. I was wanted to use the JSR 303 stuff on my beans and let Spring annotate them in the front end like I'd been doing with earlier Hibernate Annotations versions. That was pretty much the main goal and it's just about the least amount of code that can easily accomplish it. Then of course there were some validations I wanted, like email addresses, urls and stuff so I pulled them all out into a separate project and I figured that since I'd find it useful someone else might too. So take it and play with it.

    I'll eventually get around to adding a licence, but it'll be something like Apache 2.

    Got any validation code lying around you want to contribute? I know you've got some phone number stuff. ;)
blog comments powered by Disqus