[jax-rs-spec users] Re: Improving the integration of JAX-RS and Bean Validation

From: Santiago Pericasgeertsen <>
Date: Thu, 12 Jan 2017 09:49:43 -0500

Hi Gunnar,

> * The first is I18N of validation error messages. If nothing else is
> configured, BV uses the JVM default Locale for accessing validation
> message bundles. For JAX-RS it'd be great if the request locale (as
> expressed via the Accept-Language header) could be used instead, if
> present. Some people achieved that using some ThreadLocale hackery
> [1], but mandating this behaviour in the JAX-RS spec would be much
> more convenient.

 Of course, this makes perfect sense.

> * The other thing is means of disabling automatic validation of BV
> constraints as part of the JAX-RS request lifecycle. That's based on a
> request by Antonio Goncalves [2] and it seems reasonable to me.
> Similar to the BV integration of JSF and JPA, there could be a
> JAX-RS-defined property for controlling the validation behaviour,
> allowing to disable it if needed, e.g. during certain kinds of
> testing. It could look very similar to the property JPA defines for
> that purpose:
> javax.persistence.validation.mode={auto|callback|none}
> "auto" will perform validation during the entity lifecycle if a BV
> provider is present. So will "callback", with the difference that it
> raises an exception if no BV provider is present. "none" will disable
> validation.

 It would also be nice to support injection of validation errors for further processing by the JAX-RS instance. This is something that was found necessary in the context of MVC. Sometimes an exception is too extreme an outcome; programmatically inspecting validation errors and crafting a response seems useful.

 If you have a few mins, it would good to capture your suggestions as JIRAs [1]. We plan to address the new big-ticket items first and then go over those JIRAs.


— Santiago

[1] <>