Bean Validation
Jakarta Bean Validation (formerly Java Bean Validation / JSR 380) is a Java specification providing a standardized constraint model and API for validating Java beans using annotations. It defines built-in constraints (@NotNull, @Size, @Min, @Max, @Pattern, @Email, etc.), a Validator API, constraint inheritance, and method/constructor parameter validation. The current stable release is Jakarta Validation 3.1. Hibernate Validator is the reference implementation. The specification is governed by the Jakarta EE Working Group under the Eclipse Foundation.
APIs
Jakarta Bean Validation Specification 3.1
The Jakarta Bean Validation 3.1 specification defines the constraint model, annotation processor, Validator API, method validation, group sequences, cascaded validation, constra...
Hibernate Validator
Hibernate Validator is the reference implementation of Jakarta Bean Validation. Version 9.1.0.Final implements the Jakarta Validation 3.1 specification. It provides the Validato...
Jakarta Validation API
The Jakarta Validation API JAR provides the interfaces, annotations, and exception types that constitute the Bean Validation specification contract. Constraint annotations (@Not...
Features
Define validation constraints on Java beans using annotations such as @NotNull, @Size, @Min, @Max, @Pattern, @Email, and @Past.
Validate method and constructor parameters and return values using constraint annotations on method signatures.
Compose multiple constraints together using @Constraint and meta-annotations to create custom reusable constraint annotations.
Define validation groups and group sequences for ordered, conditional validation scenarios.
Trigger validation of nested objects using @Valid annotation for graph-level constraint validation.
Build and configure validators programmatically using the Validator and ValidatorFactory APIs without annotations.
Use Cases
Validate request body and query parameters in JAX-RS and Spring REST controllers using Bean Validation annotations.
Validate user-submitted form data in Jakarta Faces, Spring MVC, and other web frameworks.
Enforce business rules and data integrity constraints on JPA entity classes and domain objects.
Validate inter-service request and response payloads to enforce API contracts in microservices architectures.
Integrations
Spring integrates Jakarta Bean Validation for controller method argument validation and service layer validation.
JPA providers call the Validator API before persisting entities to enforce database-layer constraint validation.
Quarkus uses Hibernate Validator as its Bean Validation implementation with zero-config support in native images.
Jakarta Faces integrates Bean Validation for automatic form field validation in web applications.
Micronaut Framework uses Bean Validation for controller parameter and return value validation.