The context:
I have a REST API in my Spring Boot backend app. This REST API has HTTP POST endpoint with a request body. This request body as a java DTO class contains several fields (attributes). I added jakarta.validation.constraints
annotations like @NotNull
@NotEmpty
and others to these fields to validate input data.
Now:
If any of these fields violate these jakarta.validation.constraints
annotations constraints it immediately throw an exception which of course I catch with ExceptionHandler class
which return HTTP 400 Bad Request with the proper error message. The issue is that with that approach I cannot provide all fields validation violations to user to give the user the whole understanding which fields input are incorrect which are correct because an exception is thrown after just validation first wrong input.
I need:
I need that I have opportunity to send the user an error message with all all fields validation violations.
My app has:
org.springframework boot 3.2.5 version
java 17