users@jsonb-spec.java.net

[jsonb-spec users] Integrating JSON-B with Bean Validation

From: <gunnar.morling_at_googlemail.com>
Date: Wed, 8 Mar 2017 16:34:57 +0000 (UTC)

Hi,

I'm the lead of Bean Validation 2.0 (JSR 380) and have been following
the development of JSON-B with great interest.

One thing I was wondering is whether it'd be helpful to integrate the
two technologies. More specifically, JSON-B could trigger a validation
of the unmarshalled object in the course of fromJson() calls - in case
a Bean Validation provider is present. That way people would be sure to
hold a valid instance in their hand after unmarshalling. Of course
there could be an option to turn off validation entirely and it'd
likely make sense to have this as the default so to not validate twice
when e.g. using JSON-B via JAX-RS.

It'd be just a small addition but I think it make the life of users
simpler, as they don't need to explicitly trigger validation but it'd
happen automatically for them, which is a pattern successfully employed
by JPA, JSF, JAX-RS and other specs.

Looking foward to your feedback and hearing what you think about this
proposal.

Thanks,

--Gunnar