Thanks. Ideally Hibernate Validator would provide a way to set a default for this (say, for this unwrappable type, default unwrap validated value to true) but I could not find a way to do this now. @UnwrapValidatedValue is also marked as experimental.
For the time being we build a maven plugin that uses javaassist to auto-add @UnwrapValidatedValue to any resource method parameters that need it. It's ugly, but it works. On Monday, September 12, 2016 at 11:33:04 PM UTC-4, Evan Meagher wrote: > > As far as I understand it, you're correct—an @UnwrapValidatedValue > annotation is required anywhere you use a LongParam (or IntParam, > UUIDParam, etc) along with a validation annotation. > > This is rather unfortunate. The other typical use case for the > @UnwrapValidatedValue annotation is within representation classes > <http://www.dropwizard.io/1.0.0/docs/manual/core.html#man-core-representations>, > > in which case you can simply annotate the affected field once and forget > about it in your resource classes. > > On Fri, Sep 9, 2016 at 8:55 AM, Chris Micali <[email protected] > <javascript:>> wrote: > >> Hey Guys, >> >> I'm in process trying to upgrade a DW 0.8.x application to 1.0 and >> I've run into something I am not sure I understand. We have a lot of >> endpoints that include LongParams, for example: >> >> @GET >> @UnitOfWork >> public List<User> getAll(@NotNull @QueryParam("account_id") LongParam >> accountId >> >> This no longer works, as we now get a: >> >> HV000186: The constraint of type 'javax.validation.constraints.NotNull' >> defined on 'getAll.account_id' has multiple matching constraint >> validators which is due to an additional value handler of type >> 'io.dropwizard.jersey.validation.ParamValidatorUnwrapper'. It is unclear >> which value needs validating. Clarify configuration via >> @UnwrapValidatedValue. >> >> So, I understand this probably now needs @UnwrapValidatedValue after >> reading >> http://www.dropwizard.io/1.0.0/docs/manual/validation.html#optional-t-constraints >> >> >> But: does this mean *everywhere* we want to make a long parameter >> required we have to add that annotation? >> >> This is such a basic and common case, the following seems very verbose: >> >> @GET >> @UnitOfWork >> public List<User> getAll(@UnwrapValidatedValue @NotNull @QueryParam( >> "account_id") LongParam accountId >> >> Am I missing something? >> >> Thanks, >> Chris >> >> -- >> You received this message because you are subscribed to the Google Groups >> "dropwizard-user" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Evan Meagher > -- You received this message because you are subscribed to the Google Groups "dropwizard-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
