From e59a643e20a640c047b0bb175e957dbf8c7fc529 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Thu, 24 Oct 2019 16:02:59 -0700 Subject: [PATCH] Emphasize the need of @Valid on nested configuration properties Closes gh-18198 --- .../src/main/asciidoc/spring-boot-features.adoc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 8368cf07501..1cfb775aea6 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -1215,8 +1215,7 @@ To do so, ensure that a compliant JSR-303 implementation is on your classpath an TIP: You can also trigger validation by annotating the `@Bean` method that creates the configuration properties with `@Validated`. -Although nested properties will also be validated when bound, it's good practice to also annotate the associated field as `@Valid`. -This ensures that validation is triggered even if no nested properties are found. +To ensure that validation is always triggered for nested properties, even when no properties are found, the associated field must be annotated with `@Valid`. The following example builds on the preceding `AcmeProperties` example: [source,java,indent=0]