-
Notifications
You must be signed in to change notification settings - Fork 22
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
Named @RestForm and error mapping of the violations #248
Comments
See issue quarkiverse#248
Ah yes, good point. We need to add logic to find the original form name. If you're up for making a PR, I can help you. |
I just implemented the unit test in a10cd25, but I would need some pointer on "logic to find the original form name" because right now I have no clue how it is supposed to be done. |
Unfortunately, we don't have any logic in Quarkus REST to reverse-map parameters back to their HTTP form name (or query, or header, or cookie). It should be doable for simple cases, though, in Once you get the right parameter, you can load its annotations and if you see a This won't work for bean params, though, but we can add support for them later, let's not over-engineer this for now. |
This is an other potential issue, but right now if you use |
Are you sure? Did you add |
Thank you for the pointer, I was not aware of the So for the second example of the page https://docs.quarkiverse.io/quarkus-renarde/dev/advanced.html#_the_endpoint (with the FormData). This applies the validations: @Consumes(MediaType.MULTIPART_FORM_DATA)
@POST
public void complete(@RestQuery String confirmationCode,
@Valid FormData form) {
// do something with the form parameters
} public static class FormData {
@RestForm @NotBlank @Length(max = Util.VARCHAR_SIZE) String userName;
@RestForm @NotBlank @Length(min = 8, max = Util.VARCHAR_SIZE) String password;
@RestForm @NotBlank @Length(max = Util.VARCHAR_SIZE) String password2;
@RestForm @NotBlank @Length(max = Util.VARCHAR_SIZE) String firstName;
@RestForm @NotBlank @Length(max = Util.VARCHAR_SIZE) String lastName;
} With the same limitation as the one discussed in this issue: public static class FormData {
@RestForm("foo") @NotBlank @Length(max = Util.VARCHAR_SIZE) String userName;
//...
} The validation works, but is set on errors map with the key |
OK, so same problem, I suspected. |
The
@RestForm
annotation is accepting a value which is the name of the parameter.So it is valid to name the the parameter:
But in this case the the validation is executed (
hasError()
returns true) but the error is placed on the"userName"
key. I would have expected to have them on"u"
.Is that expected?
The returned violations here do not seems to contains this information:
quarkus-renarde/runtime/src/main/java/io/quarkiverse/renarde/util/MyValidationInterceptor.java
Lines 34 to 35 in 7533edc
So the mapping to the
lastNode
key seems difficult to change:quarkus-renarde/runtime/src/main/java/io/quarkiverse/renarde/util/Validation.java
Lines 101 to 110 in 7533edc
The text was updated successfully, but these errors were encountered: