Spring Boot MVC: validate a multipart/form-data RequestBody
Hello! I have the need to fill a form with some meta data and a file. The meta data required fields depends on the media "type" that you're selecting from a drop-down.
I've thus created a custom validator, associated to a custom annotation and put all on the PostMapping action annotating the parameter with
@Valid @MyCustomAnnotation
(see below). The thing is that the validator is not being called for a reason beyond my knowledge. May you please help me understand what I'm doing wrong?
Thank you very much 🙂
The DTO + validator:
The controller's method:
I've shortened the code as much as possible to stay in the chars limit, please ask me anything which might be related.
Thank you very much!7 Replies
⌛
This post has been reserved for your question.
Hey @elegos! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
I've created a poc for this issue, if you might help: https://drive.google.com/file/d/1C1klw96HCU4UbrCsjRAq4jsgI60lX4E4/view?usp=sharing
Google Docs
spring-poc.zip
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one.
Still unanswered. Can you help me please? In few words: is it possible to create a validator for the whole model, instead of the single attributes? Thank you 🙂
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@366713959396409346>.