-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quarkus cannot use the hibernate-validator constraints in the inherited class/interface #1888
Comments
I discussed with @isikemre on Zulip. Currently, it's not implemented, we need to implement it. |
…te validator constraints
…te validator constraints
I opened a PR (as discussed on Zulip) which includes a test case about this issue. |
We can workaround by adding @Valid annotations on both interface and implementation, but the fact that the annotations are gettting ignored on the interface leads to triggering of io.quarkus.hibernate.validator.runtime.interceptor.MethodValidationInterceptor instead of io.quarkus.hibernate.validator.runtime.jaxrs.JaxrsEndPointValidationInterceptor. Hence the exception is not wrapped as a ResteasyViolationException and the response code is 500 instead of 400 which would be the expected. |
Is there any updates/news for this issue? |
After a discussion with @mkouba , here is what we should do:
Note that we don't need to be too picky because HV should take care of doing nothing if we end up trying to validate things on a unconstrained method. But it has some overhead so if we can try to filter out the methods, it would be better. |
@aguibert this one is yours if you're interested. It's a good opportunity to have a look to the Jandex and annotation transformer infrastructures. |
I can have a look, and will pick up the test from the above PR (thank you!) |
Thank you, @Sanne ! |
I imported the dependency below into pom.xml
|
If you use constraints from the hibernate-validator like here but in a parent interface (or class) the constraints don't work.
Scenario
ExampleResourceImpl is implementing ExampleResource (it's a interface).
ExampleResource has all
@GET
and@Path
(JAX-RS) annotations and has also all hibernate validation constraints like@Valid
@NotNull
.ExampleResourceImpl.java
ExampleResource.java
Summary
Quarkus can read the JAX-RS annotations, but not the hibernate-validator constraints from his parent class/interface.
The text was updated successfully, but these errors were encountered: