The Bean Validation reference implementation. - Hibernate Validator
ORM
About
Releases
Documentation
Quickly
Migration guides
Books
Processor
Tooling
Envers
Contribute
Paid support
Source code
Issue tracker
Security issue
Forum
CI
Roadmap
About
Releases
Documentation
Migration guides
More resources
Roadmap
Contribute
Tooling
Paid support
FAQ
Source code
Issue tracker
Security issue
Forum
Wiki
CI
Validator
About
Releases
Documentation
Migration guides
Roadmap
Contribute
Tooling
Paid support
FAQ
Source code
Issue tracker
Security issue
Forum
CI
Reactive
About
Releases
Documentation
Contribute
Paid support
Source code
Issue tracker
Security issue
Forum
CI
Repositories
About
Releases
Documentation
Quickly
Source code
Issue tracker
Security issue
Others
Community
Community
Governance
Commonhaus - Membership
Commonhaus - Joining FAQ
Contribute - Guidelines
Contribute - Set up IntelliJ IDEA
Contribute - Set up Eclipse IDE
Contribute - Build Hibernate ORM
Team
Contributors to ORM
Contributors to Search
Contributors to Validator
Contributors to Reactive
Contributors to Tools
Contributors to OGM
Corporate contributors
Licenses
Keys
Integrations
Support
Getting help
Compatibility Policy
Maintenance Policy
Long-Term Support
End-of-Life Support
Blog
Forums
Skip to content
ORM
Validator
Reactive
Repositories
Others
Blog
Forums
Community
Support
Hibernate Validator
The Bean Validation reference implementation.
Getting started
Latest stable (9.1)
Express validation rules in a standardized way using annotation-based constraints and benefit from transparent integration with a wide variety of frameworks.
About
Releases
Overview
9.1
latest stable
9.0
limited-support
8.0
limited-support
6.2
limited-support
Documentation
Migration guides
Roadmap
Contribute
Tooling
Paid support
FAQ
Source code
Issue tracker
Security issue
Forum
CI
Released under the
ASL v2
Validation across multiple layers
Hibernate Validator expresses constraints using annotations.
public
class
Car
@NotNull
private
String
manufacturer;
@NotNull
@Size
(min =
, max =
14
private
String
licensePlate;
@Min
private
int
seatCount;
// ...
If necessary, the constraints may be overridden in XML.
Such constraints are not tied to a specific architectural tier, programming model, or framework.
Constraints might apply to entity classes, Jakarta Data
repository methods
, or Jakarta RESTful web service endpoints.
And Validator is not tied to the server—it works just as well for client-side Java programming.
Bean Validation reference implementation
Hibernate Validator is the reference implementation for the
Bean Validation
specification.
Indeed, the original specification was inspired by an early version of Hibernate Validator.
Bean Validation is an integral part of the Jakarta platform, incorporated by the Persistence, Data, RESTful Web Services, MVC, and Faces specifications, and by that black sheep of the Hibernate family,
CDI
Programmatic or automatic constraint validation
Constraints may be validated programmatically, but many Java frameworks and libraries—including Hibernate ORM—feature built-in support for Bean Validation, making it easy to enforce the constraints completely declaratively.
For example, a constraint is validated automatically if it applies to:
a field of an entity class,
a parameter of a repository method, or
a parameter of a RESTful web service endpoint.
To see all this in action, you can try out
Hibernate Validator in Quarkus
Custom constraints
The Bean Validation standard specifies a range of predefined constraint types, and Hibernate Validator adds even more, even including some country-specific constraint types such as
@TituloEleitoral
But the true power of Bean Validation lies in how easy it is to define
custom constraints
precisely capturing the semantics of application-specific types.
Rich metadata API
The Bean Validation
metadata API
facilitates tooling integration and metaprogramming.
Naturally, Hibernate Validator goes beyond the spec.
The
programmatic constraint configuration API
allows constraints to be created programmatically.
Compile-time type safety
The annotation-based approach is by nature quite type safe, but there’s even an
annotation processor
which raises compilation errors when constraint annotations are used incorrectly, for example, if the
@Past
annotation is applied to a field of type
String
Integration with Hibernate ORM
Hibernate ORM not only validates constraints automatically before writing to the database; it even adjusts the DDL generated by the schema management tooling to reflect certain constraints such as
@Size
@NotNull
@NotBlank
@Max
@Min
, and
@Digits
Latest news
Other news
Projects
Hibernate ORM
Hibernate Search
Hibernate Validator
Hibernate Reactive
Hibernate Tools
Other projects
Blog
Contribute and community
Community resources
Our GitHub organization
Submit a bug
Our forums
Report a security issue
License
Copyright ©
Hibernate.
For details on our trademarks, please visit our
Trademark Policy
and
Trademark List.
Trademarks of third parties are owned by their respective holders and their mention here does not suggest any endorsement or association.
US