Support @Valid on container elements for handler arguments

Prior to this commit, #31870 added support for constraint annotations on
container elements for handler method argument validation. Supporting
this use case:

```
public void addNames(List<@NotEmpty String> names)
```

This commit does the same for `@Valid` annotation:

```
public void addPeople(List<@Valid Person> people)
```

Fixes gh-32964
This commit is contained in:
Brian Clozel
2024-06-05 20:02:46 +02:00
parent 7785f94c4c
commit 404c4d9d92
2 changed files with 12 additions and 3 deletions

View File

@@ -417,7 +417,7 @@ public class HandlerMethod extends AnnotatedMethod {
return true;
}
merged = MergedAnnotations.from(getContainerElementAnnotations(param));
if (merged.stream().anyMatch(CONSTRAINT_PREDICATE)) {
if (merged.stream().anyMatch(CONSTRAINT_PREDICATE.or(VALID_PREDICATE))) {
return true;
}
}