How does Spring Boot support data validation?

Spring Boot supports data validation by integrating the Java Bean Validation API (JSR-380), implemented by Hibernate Validator, directly into the web layer. Developers annotate model fields with constraint annotations and Spring automatically validates incoming request data before it reaches business logic.

Key Points

Example

A UserDto class can declare @NotBlank on a name field and @Email on an email field; when a controller method is annotated with @Valid, Spring rejects malformed requests automatically without extra manual checks in the handler.

public class UserDto {
    @NotBlank
    private String name;

    @Email
    private String email;
}

@PostMapping("/users")
public ResponseEntity<User> create(@Valid @RequestBody UserDto dto) {
    return ResponseEntity.ok(userService.create(dto));
}

Interview Tip

A concise interview answer is

Spring Boot validates data using the JSR-380 Bean Validation API via Hibernate Validator. I annotate DTO fields with constraints like @NotNull or @Size, then add @Valid on the controller parameter, and Spring rejects invalid requests with a 400 before my business logic even runs.

Last updated: 16 July 2026

Previous question: You are transitioning an existing application from properties to YAML. Describe the steps and considerations involved.

Next question: Can you use custom validators in Spring Boot? How?

More Spring Boot - Level IV (Advanced) interview questions

All Spring Boot - Level IV (Advanced) questions