Skip to content

Add explanation for @Valid container parameters in ann-validation.adoc #35186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ directly on method parameters, or on the method (for the return value), then met
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`.
+
Container parameters annotated with `@Valid`—for example,
`@RequestBody List<Foo> items` or `@RequestBody @Valid List<@Valid Foo> items`—are
likewise subject to method validation. They are detected by
`HandlerMethod.MethodValidationInitializer.checkArguments(…)`, and any
resulting constraint violations cause a `HandlerMethodValidationException`
to be raised.

Applications must handle both `MethodArgumentNotValidException` and
`HandlerMethodValidationException` as either may be raised depending on the controller
Expand Down