You can learn more about the integration of Bean Validation and CDI in Section 11.3, “CDI”. Section 2.3, “Built-in constraints” provides an overview of all built-in constraints coming with Hibernate Validator.
Hibernate Validator supports running with a security manager being enabled. When using field-level constraints field access strategy is used to access the value to be validated.
In this case you can easily write your own constraint.
You can find more information in Chapter 6, As of Bean Validation 1.1, constraints can not only be applied to Java Beans and their properties, but also to the parameters and return values of the methods and constructors of any Java type.
The former allows to add tags without any attributes, whereas the latter allows to specify tags and optionally allowed attributes as well as accepted protocols for the attributes using the annotation Checks whether the given script can successfully be evaluated against the annotated element.
In order to use this constraint, an implementation of the Java Scripting API as defined by JSR 223 ("Scripting for the Java Platform") must be a part of the class path.
The expressions to be evaluated can be written in any scripting or expression language, for which a JSR 223 compatible engine can be found in the class path.
If you are using the Hibernate object-relational mapper, some of the constraints are taken into account when creating the DDL for your model (see "Hibernate metadata impact").
There are no JPMS module descriptors provided yet, but Hibernate Validator is usable as automatic modules. When a class implements an interface or extends another class, all constraint annotations declared on the super-type apply in the same manner as the constraints specified on the class itself.
package org.hibernate.validator.referenceguide.chapter01; import javax.validation.constraints. To make things clearer let’s have a look at the following example: The Bean Validation API does not only allow to validate single class instances but also complete object graphs (cascaded validation).
It is specifically not tied to either web or persistence tier, and is available for both server-side application programming, as well as rich client Swing application developers.
Hibernate Validator is the reference implementation of this JSR 380.
All the validation methods have a var-args parameter which can be used to specify which validation groups shall be considered when performing the validation.