users@jersey.java.net

Re: [Jersey] validation???

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Tue, 12 May 2009 11:24:50 -0700

On Tue, May 12, 2009 at 4:40 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
>
...
>> In Jersey I would say that using annotations would be a natural
>> choice, something like:
>>
>> @Validate(param="value", validator="ValidClass.class")
>> public void operation(int value)
>>
>> the suggestion to create a type and use it in the service context is
>> also not bad..
>>
>> * these are raw observations, suggestions and wish list only..
>>
>
> What you describe may be supported by the Bean Validation Framework (JSR
> 303):
> http://in.relation.to/Bloggers/BeanValidationJSR303PublicDraftGiveUsFeedback

I fully agree -- I think that data format schemas (W3C/XML Schema)
are both too low-level and too format-specific to be a good solution.

Regarding JAXB and JAX-RS: I think validation is an orthogonal (if
related) concern, and thus ideally JAXB (data binding) nor JAX-RS
(rest-style web service framework) would play nicely with Bean
Validation API, and not try to solve this only for their respective
use cases.

Bean Validation API has bit limited scope, but it is an on-going
effort so there may be still time to effect what it will do, and how
well RI works.
I have so far used it for simple cases (min/max values, min/max
length, not null), for which it works quite well.

-+ Tatu +-