users@jersey.java.net

Re: [Jersey] JSON Validation

From: Chris Carrier <ctcarrier_at_gmail.com>
Date: Wed, 24 Mar 2010 09:40:37 -0700

I'm not very familiar with the Java bean validation stuff. I assume
you're referring to JSR 303 like the Hibernate Validator:

http://docs.jboss.org/hibernate/stable/validator/reference/en/html_single/

How does this integrate with JAX-RS/Jersey? If I annotate my POJO's
with Hibernate Validation annotations will they automagically be
validated by Jersey? Do I still have to manually add some step to
trigger validation? I would really like to perform validation in a
more standard/less obtrusive way but at this point I'm pretty much
using a bunch of null checks after marshalling.

Any more info on this would be greatly appreciated.

Chris

On Wed, Mar 24, 2010 at 8:51 AM, Tatu Saloranta <tsaloranta_at_gmail.com> wrote:
> On Wed, Mar 24, 2010 at 2:04 AM, Jakub Podlesak <Jakub.Podlesak_at_sun.com> wrote:
>>
> ...
>> When implementing the JSON API, we have not thought about validating JSON using the XML schema validation
>> of the intermediary XML data, but i think it is generally not a bad idea for the JAXB/JSON scenario.
>>
>> Regarding the current behavior, even if we put aside the JSON validation, i think you should be able to validate
>> XML wthout breaking the JSON functionality.
>
> Another way to consider would be to forget about data format level (it
> is often too low-level anyway) and instead use bean validation API. It
> is used by annotating POJOs to define constraints.
>
> For output side you would probably want to serialize, deserialize
> back, validate. This would actually work better than plain old
> writer-side validation because it would test whether data can be read
> back, not just whether it comes out as defined by schema (by using
> jerser/jax-rs).
>
> Just an idea,
>
> -+ Tatu +-
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>