Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Validation framework recommendations?  RSS feed

 
Matt Dalen
Greenhorn
Posts: 19
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm building a rest service based on the Spark framework, and I'm trying to figure out the best way to run field-level validation on the pojos being passed in. Most of the discussions of various validation frameworks I've found online are either several years old or just basically a list of options, with no discussion of their relative benefits. Does anyone have any recommendations? I'm looking for a (hopefully lightweight and easy-to-configure) framework that will validate fields in the pojos based on an xml config file, testing against requirements such as string length, numerical min/max, and basic regex validation.
 
Leo Ribeiro
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Hibernate Validator http://hibernate.org/validator/ and I'm being very happy!

It's very simple to use and setup, you just do annotations in your pojos.
 
Nico Van Brandt
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not stick to JSR 303 - Bean Validation? Don't focus too much on the amount of predefined constraints. It is really simple to create your own. Just create an annotation and a class which serves as the implementation.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!