Meaningless Drivel is fun!
The moose likes EJB and other Java EE Technologies and the fly likes Which validation framework to use? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Which validation framework to use?" Watch "Which validation framework to use?" New topic

Which validation framework to use?

nithin chinni
Ranch Hand

Joined: Dec 02, 2010
Posts: 41
In our web service project we are looking for a validation framework on java objects.
I tried iscreen which is pretty good but it does not have a maven repository. (Not sure if the code is production ready)
Tried spring validator which does not have much validations.
Tried using commons validator which did not look comfortable.
Tried JSR 303, they have only annotation based validation. Our beans are jaxb generated so we cannot put custom annotations. We can do it but its very hard.
We cannot use XSD schema validation before converting to jaxb objects because we accept both XML and JSON's as Input. (Wanted to convert JSON object to XML again for validation but its not a recommended architecture).

Any other alternatives???
Bill Gorder

Joined: Mar 07, 2010
Posts: 1682

Well I still think JSR-303 is the way to go. The framework to use for that is Hibernate Validator

Now my first choice would be don't generate the Jaxb objects. In my opinion a lot of Object factories and unnecessary meta data is generated with it. Create your objects and annotate them how you want them then they can easily be used for XML and JSON as well as adding the JSR-303 annotations to them.

If you decide that you want to keep generating the objects you can either map them to JSR-303 annotated objects using a mapping library like Dozer or you can use xml to apply the JSR-303 rules to your generated objects and just use the generated objects themselves. See the documentation for that HERE.

[How To Ask Questions][Read before you PM me]
James Boswell

Joined: Nov 09, 2011
Posts: 1051

Check out OVal (stands for Object Validation):

Configuration can be applied using XML or annotations.
Fox Mulder

Joined: Jan 08, 2013
Posts: 1
You can try Java Validation Framework that located in maven central.
I agree. Here's the link:
subject: Which validation framework to use?
It's not a secret anymore!