We are evaluating Spring 5 for a project, and not sure how best to validate Mono parameters. Traditionally we had been using MethodValidationPostProcessor to validate our method parameters as below:
@Validated
@Service
public class FooService
@Validated(SignUpValidation.class)
public void signup(@Valid UserCommand userCommand) {
...
}
We would then handle the exception in a ControllerAdvice or ErrorController, and pass a suitable 4xx response to the client.
But when I change the parameter to Mono, as below, it no more seems to work.
@Validated
@Service
public class FooService
@Validated(SignUpValidation.class)
public Mono<Void> signup(@Valid Mono<UserCommand> userCommand) {
...
}
As I understand Spring Reactive, probably it's actually not supposed to work. So, what would be Spring 5 best practices for validating Monos and Fluxes, and then sending a suitable error response?