Book Image

Mastering Netbeans

5 (1)
Book Image

Mastering Netbeans

5 (1)

Overview of this book

Table of Contents (17 chapters)
Mastering NetBeans
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The Java Bean Validation framework


The Java Bean Validation framework 1.0 (JSR 303) was introduced into Java EE 6 to allow validation constraints to be added onto Java beans. The latest release of the Bean Validation framework, version 1.1 (JSR 349), further enhances the validation model, allowing additional features such as method level validation and full support for CDI.

Bean Validation works by adding a constraint onto a field, method, or class in the form of an annotation. The framework provides many constraints as well as an API, allowing new constraints to be developed. Some of the more common annotations are:

  • @NotNull: The value of the property must not be null

  • @Pattern: The value of the property conforms to the specified regular expression

  • @Max / @Min: The value of the property must be an integer with the specified maximum/minimum value

  • @Future / @Past: The value of the property must be a data in the future/past

Of course, there are many more validation constraint annotations than...