Why are javax.validation annotations being enforced throughout the application code ? #35505
Unanswered
kirankolli-addepar
asked this question in
Q&A
Replies: 1 comment
-
How is EmployeeModel being instantiated? Is it a managed bean or a POJO? How are you doing the copy? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Scenario :
Quarkus version 2.16.5Final , RestEasy Rest End point which uses Hibernate validation for validation.
Incoming Request POJO
@Valid class Employee{ @NotEmpty String empId; String deptId; }
Upon receiving such a request I copy this over to a model class within my application code. The model class looks like this :
@Valid class EmployeeModel{ @NotEmpty String empId; String deptId; }
Now if I happen to have a bug in my application code due to which I end up not copying the field 'empId' from the request to the model class what I see is that Quarkus is enforcing the validation on the model class and as a result rejecting the request with Status Code 400 Bad Request.
This seems wrong. Shouldn't Hibernate validation in Quarkus applications only be applied on the incoming requests ? And even if they are applied inside application code a rejection arising out of this should not be rejected with 400 Status code, right ?
Beta Was this translation helpful? Give feedback.
All reactions