Files
spring-boot/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/validation.adoc
Phillip Webb 711a0c19e6 Use consistent asciidoctor subs attribute
Closes gh-25101
2021-05-04 13:01:20 -07:00

13 lines
749 B
Plaintext

[[features.validation]]
== Validation
The method validation feature supported by Bean Validation 1.1 is automatically enabled as long as a JSR-303 implementation (such as Hibernate validator) is on the classpath.
This lets bean methods be annotated with `javax.validation` constraints on their parameters and/or on their return value.
Target classes with such annotated methods need to be annotated with the `@Validated` annotation at the type level for their methods to be searched for inline constraint annotations.
For instance, the following service triggers the validation of the first argument, making sure its size is between 8 and 10:
[source,java,indent=0,subs="verbatim"]
----
include::{docs-java}/features/validation/MyBean.java[]
----