I have test spring-boot-starter-validation behaviour and noticed that: request body is validated first throwing a WebExchangeBindException and then request path&query parameters are validated throwing a ConstraintViolationException. So, how to join these two groups of constraints in a single Exception catched in a single response body?
Expected response body:
{
"address": "must not be blank",
"mail": "must be a well-formed email address",
"floor": "floor cannot be null",
"control.mark": "must be less than or equal to 5",
"control.infect": "must be greater than 0",
"control.age": "must be greater than or equal to 5"
}
Actual request body fields constraints:
{
"address": "must not be blank",
"mail": "must be a well-formed email address",
"floor": "floor cannot be null"
}
Actual query and path parameters constraints:
{
"control.mark": "must be less than or equal to 5",
"control.infect": "must be greater than 0",
"control.age": "must be greater than or equal to 5"
}
Here is an integration test for a better understanding link
Dependencies:
- spring-boot version 2.7.2
- spring-boot-starter-webflux
- spring-boot-starter-validation