users@jersey.java.net

[Jersey] Re: Best way to validate request objects in jersey?

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Wed, 31 Oct 2012 17:10:21 -0700

On Wed, Oct 31, 2012 at 11:19 AM, Marek Potociar
<marek.potociar_at_oracle.com> wrote:
> The recommended way how to validate objects in Java in general is to use standard Bean Validation APIs. Unfortunately, neither Jersey nor JAX-RS provides a BV integration at the moment, so you may need to invoke the BV Validator manually yourself. At least for now. There are some plans to add BV support to JAX-RS, but nothing is fleshed out at the moment.

In the meantime, I'd strongly suggest a look at:

http://dropwizard.codahale.com/

which already nicely integrates Bean Validation & Jersey. And in case
JAX-RS would in future open up extension points to do the same, I'm
sure DW could easily wire things using that.

In case of DW, one then just annotates request POJOs with Bean
Validation annotations and things "just work".
Similar to JAX-RS databinding.
And this can be used not just for data but also service configuration,
which is totally awesome.

-+ Tatu +-