Skip to content
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

Add Validation for Multipart Form Type using resteasy reactive #26451

Closed
abuelgasimsaadeldin opened this issue Jun 29, 2022 · 11 comments
Closed
Assignees
Labels
area/rest kind/enhancement New feature or request triage/invalid This doesn't seem right

Comments

@abuelgasimsaadeldin
Copy link

Description

Previously when using the quarkus-resteasy-multipart we could add validation to dto requests such as @NotNull and @notblank however after migrating to resteasy reactive we are unable to add validations.

Implementation ideas

Add validations similar to previous quarkus-resteasy-multipart.

@abuelgasimsaadeldin abuelgasimsaadeldin added the kind/enhancement New feature or request label Jun 29, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 29, 2022

/cc @FroMage, @geoand, @stuartwdouglas

@geoand
Copy link
Contributor

geoand commented Jun 30, 2022

This actually already works!

You just need to annotate the @Multipart method parameter with @Valid as well, see #26459 for an example

@geoand geoand closed this as not planned Won't fix, can't repro, duplicate, stale Jun 30, 2022
@geoand geoand added the triage/invalid This doesn't seem right label Jun 30, 2022
@abuelgasimsaadeldin
Copy link
Author

abuelgasimsaadeldin commented Jun 30, 2022

Hi @geoand, yes if I'm not mistaken the javax.validation library before came by default with the previous quarkus-resteasy-multipart however with the new reseasy reactive it does not come with the @Valid annotation by default so may I know the dependency that is required to be added to my pom.xml to be able to use this library? Thanks!

@geoand
Copy link
Contributor

geoand commented Jun 30, 2022

Yeah, to get @Valid and friends just add quarkus-hibernate-validator to your dependencies.

@abuelgasimsaadeldin
Copy link
Author

Thanks!

@geoand
Copy link
Contributor

geoand commented Jun 30, 2022

🙏🏼

@abuelgasimsaadeldin
Copy link
Author

abuelgasimsaadeldin commented Jun 30, 2022

Hi @geoand I have another simple inquiry if you do not mind regarding the request dto, previously before migrating to resteasy reactive I used to have the @FormParam annotation providing the KEY value for the request and String variable for the variable initialization, however I noticed that now the KEY value is using the variable name if that makes sense.

For example:

    @FormParam("destination_country")
    @PartType(MediaType.TEXT_PLAIN)
    private String destinationCountry;

and in Swagger instead of of setting the KEY to "destination_country" (which is required) it instead uses "desinationCountry" which gives out errors so I had to initialize my variables with String destination_country which I believe is not common practice and instead should be using camelCase, your input in this is highly appreciated. Thanks.

Example swagger UI when setting @FormParam("destination_country") and String destinationCountry:
image

Expected swagger UI:
image

@geoand
Copy link
Contributor

geoand commented Jun 30, 2022

Can you please open a new issue for this?

@abuelgasimsaadeldin
Copy link
Author

@geoand yes, sure

@abuelgasimsaadeldin
Copy link
Author

@geoand Done created, I was not sure whether to submit it as a bug or question so I apologize if it I had mistakenly grouped it wrongly. But here it is: #26461

@geoand
Copy link
Contributor

geoand commented Jun 30, 2022

Thanks

gsmet added a commit that referenced this issue Jun 30, 2022
Add test for multipart and validation combination
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest kind/enhancement New feature or request triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants