users@jersey.java.net

Re: [Jersey] validation & logging

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Thu, 30 Apr 2009 13:07:32 -0700

2009/4/30 Felipe Gaścho <fgaucho_at_gmail.com>:
> below you find an example of resource that returns a collection of
> entities with pagination ...
>
> I was thinking in a standard way to move the logging and validation
> from this code to something external..

I don't know if this would help, but the Bean Validation API (jsr-303,
an impl at https://www.hibernate.org/412.html) helps in modularizing
validation part.

You can annotate fields (or accessors for fields) with constraints,
and get it check for violations, which can be processed generically. I
use this for validating web service requests; much cleaner than trying
to use something like XML schema (IMO).

It may not be a big win for just 2 fields (min, max), plus it's more
useful with static checks. It can probably handle co-constraints too
(field1 <= field2 etc), but I haven't had (time) to check that part
yet.

-+ Tatu +-