Garzec
Explore posts from serversJCHJava Community | Help. Code. Learn.
•Created by Garzec on 1/12/2025 in #java-help
How to apply request body validation with error details?
Hello there,
I want to apply request body validation to my Spring project
and this endpoint
I thought
@Valid
would handle it for me but actually the API consumer still gets a 400 without any error details. So the consumer doesn't know what's wrong.
After googling around I think Spring doesn't do that for me out of the box. So I created an additional class
Unfortunately the result is the same, the API consumer won't get any error details. Is something missing? Do I even need the ValidationExceptionHandler
? How do I achieve this?
Thanks! 🙂56 replies