Bean Validation

Bean Validation 2.0 (JSR 380)

Bean Validation 2.0 (JSR 380) was finished in August 2017.

It's part of Java EE 8 (but can of course be used with plain Java SE as the previous releases).

Certified implementations

Name Version RI
Hibernate Validator 6.0.1.Final

TCK

The TCK for Bean Validation 2.0 can be found here .

Changes between Bean Validation 2.0 and 1.1

Bean Validation 2.0 focused on the following topics:

  • 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 container types

    • support for java.util.Optional

    • support for the property types declared by JavaFX

    • support for custom container types

  • support for the new date/time data types (JSR 310) for @Past and @Future

  • new built-in constraints: @Email, @NotEmpty, @NotBlank, @Positive, @PositiveOrZero, @Negative, @NegativeOrZero, @PastOrPresent and @FutureOrPresent

  • leverage the JDK 8 new features (built-in constraints are marked repeatable, parameter names are retrieved via reflection)

You can consult an HTML diff between the 1.1 specification and the 2.0 specification here.

For more information, check out the full list of changes.

History

If you are interested in the various drafts that led to Bean Validation 2.0, check out the history page.

Feedback

Do you have feedback? Talk to us:

If you want to take the next step and contribute, read how to contribute.