Reputation: 1663
Context :
I am using Jakarta with RestEasy. I have a simple endpoint such as this one :
@GET
@Path("expectsLong")
@Produces(MediaType.TEXT_PLAIN)
public Response expectsLong(
@QueryParam("searchValue") final Long searchValue)
{
return ok(searchValue);
}
I am focused on applying some validation with annotations only (I'm not following the ParamConverter
approach). For example :
@NotNull @Min(1) @Max(10) @QueryParam("searchValue") final Long searchValue)
By design, all of those annotations come into effect only after the initial step, which is the parsing from String to Long.
(Side note: If you try to use an annotation that has nothing to do with the expected parameter's type (for example: If you tried to use @Pattern on searchValue
, which is a Long) then you would get the infamous error HV000030: No validator could be found for constraint
)
Problem :
The parsing step is a bit of an alien in that flow:
My approach :
It seems to me that I need to customize the very first step, the parsing step.
Question :
is it possible to provide a custom parser to RestEasy?
Upvotes: 0
Views: 30