For faster navigation, this Iframe is preloading the Wikiwand page for Bean Validation.

Bean Validation

Bean Validation defines a metadata model and API for JavaBean validation. The metadata source is annotations, with the ability to override and extend the meta-data through the use of XML validation descriptors.

Originally defined as part of Java EE, version 2 aims to work in Java SE apps as well.

Java Bean Validation (JSR 303) originated as a framework that was approved by the JCP as of 16 November 2009 and accepted as part of the Java EE 6 specification. The Hibernate team provides with Hibernate Validator the reference implementation of Bean Validation and also created the Bean Validation TCK any implementation of JSR 303 needs to pass.

Current Version

[edit]

Bean Validation 2.0 is defined by JSR 380, approved 2017-07-31. This major release leverages language features in Java 8 that are very useful for the purposes of Bean Validation. So Java 8 is required as the minimum Java version.

Other changes include:

  • 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 new date/time data 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 now
  • Parameter names are retrieved using reflection
  • ConstraintValidator#initialize() is a default method
  • The namespace for Bean Validation XML descriptors has been changed to http://xmlns.jcp.org/xml/ns/validation/configuration[permanent dead link] for META- INF/validation.xml and http://xmlns.jcp.org/xml/ns/validation/mapping[permanent dead link] for constraint mapping files

Previous Version

[edit]

Bean Validation 1.1 (JSR 349) improves upon the initial version 1.0 (JSR 303). Significant changes[1] include:

  • Validation of method arguments and return value
  • Dependency Injection
  • More open process in developing the specification

Final release of the 1.1 specification occurred 2013-05-24.

References

[edit]
  1. ^ Emmanuel, Bernard. "Bean Validation 1.1 goals". Red Hat, Inc. Retrieved 2014-08-17.

Further reading

[edit]
{{bottomLinkPreText}} {{bottomLinkText}}
Bean Validation
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?