Add explanation for @Valid container parameters in ann-validation.adoc by HeeChanN · Pull Request #35186 · spring-projects/spring-framework

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that! I actually made a typo in my description — I meant to write either
@RequestBody @Valid List<Foo> items or @RequestBody List<@Valid Foo> items.

It was my mistake to put both annotations together in the example. Thanks for pointing it out!

For context, the reason I opened this PR is that when using @Valid together with a container type,
I noticed that @RequestBody @Valid List<Foo> triggers a HandlerMethodValidationException,
whereas the official documentation led me to expect a MethodArgumentNotValidException.
I thought it would be helpful to clarify this behavior in the reference documentation so that others won’t run into the same confusion.