Bean Validation with @Valid
Validate request bodies with annotations.
Bean Validation Overview
Bean Validation (JSR-380, Jakarta Validation) lets you declare constraints with annotations on your DTO fields, then validate objects against them. Spring Boot integrates it so incoming request bodies are checked automatically.
Adding the Dependency
The validation API plus an implementation (Hibernate Validator) come via the validation starter. Adding it activates annotation-driven validation in controllers.
<!-- pom.xml -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>All lessons in this course
- Bean Validation with @Valid
- Custom Validators
- @ControllerAdvice and @ExceptionHandler
- Problem Details (RFC 7807)