[
Date Prev][Date Next][
Thread Prev][Thread Next][
Date Index][
Thread Index]
[
List Home]
|
[jersey-dev] Bean Validation groups
|
Dear Jersey developers,
The Jersey manual writes in the section on Bean Validation (20.4): "Jersey does not support, and doesn't validate, constraints placed on constructors and Bean Validation groups (only
Defaultgroup is supported at the moment)." I originally interpreted this as 'you can't use validation groups at all with
jersey', which I found rather unfortunate considering that I have one parameter object that I need to validate in two different ways.
Recently I found a route to achieve validation of request bodies and parameters using validation groups by defining the method argument as '@Valid @ConvertGroup(to=ExampleGroup.class) RequestBodyObject body'. This will trigger a group conversion from the starting
Default group to the ExampleGroup. Subsequently it will validate the content of the body, because it's marked with @Valid, using the ExampleGroup.
I did not test whether @ConvertGroup works on the return type of a resource method annotated with @Valid. But if it does I would guesstimate that most practical use cases for bean validation groups are covered. Because it allows you to validate all more complex
input and output objects to a resource method. The largest thing that I can see not being supported is having an annotation with a group on the method argument itself (rather than inside the argument object) and then validating it with that group.
So I've two questions based on this:
-
How should I interpret the specified lack of bean validation groups? Should this be interpreted as that there is only support for starting the validation at the Default group?
-
Might it be useful to add the use of @ConvertGroup as an example to the manual? As it took me quite a bit of digging in the bean validation spec to find this route.
Kind regards,
Lars Corbijn
P.S. Many thanks for fast addition of the bean validation ClockProvider to the bean validation integration.