Skip to content

Commit

Permalink
Correct type names in docs on Validation in WebFlux
Browse files Browse the repository at this point in the history
Closes gh-33061
  • Loading branch information
rstoyanchev committed Jul 10, 2024
1 parent fa2a58b commit 611d3e5
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ xref:web/webflux/controller/ann-methods/multipart-forms.adoc[@RequestPart] argum
resolvers validate a method argument individually if the method parameter is annotated
with Jakarta `@Valid` or Spring's `@Validated`, _AND_ there is no `Errors` or
`BindingResult` parameter immediately after, _AND_ method validation is not needed (to be
discussed next). The exception raised in this case is `MethodArgumentNotValidException`.
discussed next). The exception raised in this case is `WebExchangeBindException`.

2. When `@Constraint` annotations such as `@Min`, `@NotBlank` and others are declared
directly on method parameters, or on the method (for the return value), then method
validation must be applied, and that supersedes validation at the method argument level
because method validation covers both method parameter constraints and nested constraints
via `@Valid`. The exception raised in this case is `HandlerMethodValidationException`.

Applications must handle both `MethodArgumentNotValidException` and
Applications must handle both `WebExchangeBindException` and
`HandlerMethodValidationException` as either may be raised depending on the controller
method signature. The two exceptions, however are designed to be very similar, and can be
handled with almost identical code. The main difference is that the former is for a single
Expand All @@ -39,7 +39,7 @@ method parameters with an `Errors` immediately after. If there are validation er
any other method parameter then `HandlerMethodValidationException` is raised.

You can configure a `Validator` globally through the
xref:web/webflux/config.adoc#webflux-config-validation[WebMvc config], or locally
xref:web/webflux/config.adoc#webflux-config-validation[WebFlux config], or locally
through an xref:web/webflux/controller/ann-initbinder.adoc[@InitBinder] method in an
`@Controller` or `@ControllerAdvice`. You can also use multiple validators.

Expand All @@ -49,8 +49,8 @@ through an AOP proxy. In order to take advantage of the Spring MVC built-in supp
method validation added in Spring Framework 6.1, you need to remove the class level
`@Validated` annotation from the controller.

The xref:web/webmvc/mvc-ann-rest-exceptions.adoc[Error Responses] section provides further
details on how `MethodArgumentNotValidException` and `HandlerMethodValidationException`
The xref:web/webflux/ann-rest-exceptions.adoc[Error Responses] section provides further
details on how `WebExchangeBindException` and `HandlerMethodValidationException`
are handled, and also how their rendering can be customized through a `MessageSource` and
locale and language specific resource bundles.

Expand Down

0 comments on commit 611d3e5

Please sign in to comment.