According to Webflux documentation:
https://github.com/spring-projects/spring-framework/blob/master/src/docs/asciidoc/web/webflux.adoc
You can use @RequestBody in combination with javax.validation.Valid or Spring’s @Validated annotation, which causes Standard Bean Validation to be applied. By default, validation errors cause a WebExchangeBindException, which is turned into a 400 (BAD_REQUEST) response. Alternatively, you can handle validation errors locally within the controller through an Errors or a BindingResult argument.
The following example uses a BindingResult argument:
@PostMapping("/accounts")
public void handle(@Valid @RequestBody Account account, BindingResult result) {
// ...
}
This part throws an following exception :
java.lang.IllegalStateException: An Errors/BindingResult argument is expected immediately after the @ModelAttribute argument to which it applies. For @RequestBody and @RequestPart arguments, please declare them with a reactive type wrapper and use its onError operators to handle WebExchangeBindException
Sample code :
https://github.com/flezsoftware/requestbody-bindingresult
Suggested changes to documentation :
https://github.com/spring-projects/spring-framework/pull/22993/files
and comment by @rstoyanchev #22993 (comment)
According to Webflux documentation:
https://github.com/spring-projects/spring-framework/blob/master/src/docs/asciidoc/web/webflux.adoc
The following example uses a
BindingResultargument:This part throws an following exception :
Sample code :
https://github.com/flezsoftware/requestbody-bindingresult
Suggested changes to documentation :
https://github.com/spring-projects/spring-framework/pull/22993/files
and comment by @rstoyanchev #22993 (comment)