Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which validation framework to use?

 
nithin chinni
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out OVal (stands for Object Validation):

http://oval.sourceforge.net/

Configuration can be applied using XML or annotations.
 
Fox Mulder
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try Java Validation Framework that located in maven central.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic