You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by javaworkinggirl <ja...@gmail.com> on 2014/07/28 19:19:51 UTC
Use Validation Groups with Bean Validation?
Hi.
Is there a way to use validation groups with bean validation (jsr-303) in
cxf?
Passing in the group as an parameter to @Valid doesn't work.
Other suggestions?
@POST
@Path("/entitlement")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@CsgHeaderValidation
@Valid
public Response postEntitlement(@Context final HttpServletRequest
request, @NotNull @Valid(OrderChecks.class) final CsgEntitlement
csgEntitlement) throws GenericRestException{ . . .}
My main problem is that I want to use the same object in a POST and PUT but
the validation for the PUT is a subset of the validation for the POST.
Other suggestions of how to accomplish this?
--
View this message in context: http://cxf.547215.n5.nabble.com/Use-Validation-Groups-with-Bean-Validation-tp5746998.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Use Validation Groups with Bean Validation?
Posted by javaworkinggirl <ja...@gmail.com>.
Ok.
I was able to use an abstract class with 2 subclasses with that had the
appropriate annotations for each class instead.
Thanks.
On Tue, Jul 29, 2014 at 2:47 AM, Sergey Beryozkin [via CXF] <
ml-node+s547215n5747010h46@n5.nabble.com> wrote:
> Hi
>
>
> On 28/07/14 20:19, javaworkinggirl wrote:
>
> > Hi.
> >
> > Is there a way to use validation groups with bean validation (jsr-303)
> in
> > cxf?
> >
> > Passing in the group as an parameter to @Valid doesn't work.
> > Other suggestions?
> > @POST
> > @Path("/entitlement")
> > @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
> > @CsgHeaderValidation
> > @Valid
> > public Response postEntitlement(@Context final HttpServletRequest
> > request, @NotNull @Valid(OrderChecks.class) final CsgEntitlement
> > csgEntitlement) throws GenericRestException{ . . .}
>
> The spec says: "For simplicity, JAX-RS implementations are NOT REQUIRED
> to support processing groups other than Default"
>
> It does not block such an option, but it's not something that is
> required at the moment. We can have a look and see if it is feasible...
>
> >
> > My main problem is that I want to use the same object in a POST and PUT
> but
> > the validation for the PUT is a subset of the validation for the POST.
> > Other suggestions of how to accomplish this?
> Can you create a custom validation annotation similar to @NotNull ?
>
> Cheers, Sergey
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> http://cxf.547215.n5.nabble.com/Use-Validation-Groups-with-Bean-Validation-tp5746998.html
> > Sent from the cxf-user mailing list archive at Nabble.com.
> >
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://cxf.547215.n5.nabble.com/Use-Validation-Groups-with-Bean-Validation-tp5746998p5747010.html
> To unsubscribe from Use Validation Groups with Bean Validation?, click
> here
> <http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5746998&code=amF2YXdvcmtpbmdnaXJsQGdtYWlsLmNvbXw1NzQ2OTk4fC0xMTE1Njg5NTY4>
> .
> NAML
> <http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://cxf.547215.n5.nabble.com/Use-Validation-Groups-with-Bean-Validation-tp5746998p5747050.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Use Validation Groups with Bean Validation?
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 28/07/14 20:19, javaworkinggirl wrote:
> Hi.
>
> Is there a way to use validation groups with bean validation (jsr-303) in
> cxf?
>
> Passing in the group as an parameter to @Valid doesn't work.
> Other suggestions?
> @POST
> @Path("/entitlement")
> @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
> @CsgHeaderValidation
> @Valid
> public Response postEntitlement(@Context final HttpServletRequest
> request, @NotNull @Valid(OrderChecks.class) final CsgEntitlement
> csgEntitlement) throws GenericRestException{ . . .}
The spec says: "For simplicity, JAX-RS implementations are NOT REQUIRED
to support processing groups other than Default"
It does not block such an option, but it's not something that is
required at the moment. We can have a look and see if it is feasible...
>
> My main problem is that I want to use the same object in a POST and PUT but
> the validation for the PUT is a subset of the validation for the POST.
> Other suggestions of how to accomplish this?
Can you create a custom validation annotation similar to @NotNull ?
Cheers, Sergey
>
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Use-Validation-Groups-with-Bean-Validation-tp5746998.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com