users@jersey.java.net

Re: [Jersey] Schema validation with jersey-spring

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Thu, 1 Apr 2010 22:10:30 -0700

On Thu, Apr 1, 2010 at 4:42 PM, Mike Key <mike.key_at_gmail.com> wrote:
...
> Also I've noticed a few posts to this mail alias about different validation means (JSON or XML) that people are considering as part of JSR 303.  So my more important question is...I am 100% new to
> JSR303 and am wondering if using this type of validation is becoming preferred to XML schema validation or is to be used in conjunction with schema validation?  And lastly if it is preferred to XML

I can't say for sure, but I think it is becoming more common, partly
because JSR-303 is now mature (which it was not when JAXB and JAX-RS
became mature). It is also nice because its use is quite orthogonal to
serialization aspects, meaning that it is more widely applicable than
data format specific validation.

> schema validation...do I use these annotations instead of JAXB annotations on an interface supporting JSON/XML with Jersey?

You would use them as complementary pieces: JAXB annotations to handle
data binding, and JSR-303 to indicate constraints for bean properties.
Sort of like Schema validation is an optional additional thing for
JAX-RS/JAXB. But whereas some JAXB annotations have additional
implications for XML Schema generation, there are no such side effects
for Bean Validation. Actually, JAXB annotations do not have direct
effect on schema validation, but rather they can be used to generate
schema, which can then be used for validation, so their effect would
be indirect.

-+ Tatu +-