It is done — after one year of hard work, and a bit more than four years after the previous revision, the final release of Bean Validation 2.0 (JSR 380) is out!
Last week, the JSR passed the Final Approval Ballot by the executive committee of the JCP unanimously with 25 "Yes" votes. After the ballot we’ve released version 2.0.0.Final of the specification, the API as well as the TCK. At the same time, the final version of the reference implementation, Hibernate Validator 6, was released, too.
Within the next few days, the final specification will also be available on the JSR 380 page on jcp.org, after which the work on this JSR is complete and the expert group officially will disband.
What’s new in Bean Validation 2.0?
By now, you’ll probably have heard about all the new features added in Bean Validation 2.0. Just in case you haven’t, here’s a quick summary:
-
Support for validating container elements by annotating type arguments of parameterized types, e.g.
List<@Positive Integer> positiveNumbers
; this also includes:-
More flexible cascaded validation of collection types; e.g. values and keys of maps can be validated now:
Map<@Valid CustomerType, @Valid Customer> customersByType
-
Support for
java.util.Optional
-
Support for the property types declared by JavaFX
-
Support for custom container types by plugging in additional value extractors
-
-
Support for the JSR 310 date/time types for
@Past
and@Future
; fine-grained control over the current time and time zone used for validation -
New built-in constraints:
@Email
,@NotEmpty
,@NotBlank
,@Positive
,@PositiveOrZero
,@Negative
,@NegativeOrZero
,@PastOrPresent
and@FutureOrPresent
-
All built-in constraints are marked as repeatable
-
Parameter names are retrieved using reflection
-
ConstraintValidator#initialize()
is a default method
Bean Validation 2.0 will also be part of the Java EE 8 platform, to be released later this summer.
To learn more about all the new features in Bean Validation 2.0, check out this presentation which I recently gave at the jdk.io conference.
Thank you!
I’d like to shout out a huge "Thank you" to everyone helping with the work on Bean Validation 2.0:
-
The fantastic JSR 380 expert group (thanks to Christian, Hendrik, Marco, Otavio and everyone else for their great input, proposals and much more) as well as the BV community at large (thanks to Hardy, Matt and everyone else for making themselves heard and providing feedback)
-
The former spec lead Emmanuel for his continued support with everything JCP-related and going through the details of container element validation again and again
-
My dear fellow Guillaume for his tireless work on the TCK, the reference implementation, the website and the spec; merci beaucoup!
-
Marko Bekhta who stepped up to work on the TCK which has been a very much appreciated contribution
-
Everyone participating in our polls and surveys; your replies and comments helped very much to arrive on good decisions on the different options on the table
-
The friendly folks of Oracle’s GlassFish team for all their work on integrating Bean Validation 2.0 into the Java EE 8 reference implementation
It has been a true pleasure and honor for me to make the new spec a reality together with such a fantastic community!
Give it a try
Don’t wait and try out the new release yourself! Just download the reference implementation Hibernate Validator and read the Getting started section of its reference guide. You also can read the complete specification as well as the API docs.