Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop applications that use Bean Validation API


Bean validation built-in constraints

Use this information to look up information about Bean Validation API built-in constraints.

The Bean Validation API is supported by constraints that are primarily expressed through annotations. The constraints are added to a class, field, or method of an EJB component. The annotated element value is checked by the constraint.

Constraints can be built in or user defined. Several built-in annotations are available in the javax.validation.constraints package. They are used to define regular constraint definitions and for composing constraints.

The following table is a list of constraints and usage.

Bean validation built-in constraints. Use of bean validation built-in constraints

Constraint Usage
@Null Specifies that the configuration property decorated with this annotation must have a null value. This constraint accepts any type.
@NotNull Specifies that the configuration property decorated with this annotation must not have a null value. That is, the property is required. This constraint accepts any type.
@AssertTrue Specifies that the configuration property decorated with this annotation must be true. Supported value types are boolean and Boolean. Null elements are considered valid.
@AssertFalse Specifies that the configuration property decorated with this annotation must be false. Supported value types are boolean and Boolean. Null elements are considered valid.
@Min Specifies that the configuration property decorated with this annotation must have a value greater than or equal to the specified minimum. Supported value types are BigDecimal, BigInteger, byte, short, int, long and their respective wrappers. Null elements are considered valid.
@Max Specifies that the configuration property decorated with this annotation must have a value less than or equal to the specified maximum. Supported value types are BigDecimal, BigInteger, byte, short, int, long and their respective wrappers. Null elements are considered valid.
@DecimalMin Specifies that the configuration property decorated with this annotation must have a value higher or equal to the specified minimum. Supported value types are BigDecimal, BigInteger, String, byte, short, int, long and their respective wrappers. Null elements are considered valid.
@DecimalMax Specifies that the configuration property decorated with this annotation must have a value lower or equal to the specified maximum. Supported value types are BigDecimal, BigInteger, String, byte, short, int, long and their respective wrappers. Null elements are considered valid.
@Size Specifies that the configuration property decorated with this annotation must have a value between the specified boundaries (included). Supported value types are String (string length is evaluated), Collection (collection size is evaluated), Map (map size is evaluated), Array (array length is evaluated). Null elements are considered valid.
@Digits Specifies that the configuration property decorated with this annotation must have a value within accepted range. Supported value types are BigDecimal, BigInteger, String, byte, short, int, long and their respective wrappers. Null elements are considered valid.
@Past Specifies that the configuration property decorated with this annotation must have a date in the past. Now is defined as the current time according to the virtual machine. The calendar is used if the compared type is of type Calendar and the calendar is based on the current timezone and the current locale. Supported value types are java.util.Date, java.util.Calendar. Null elements are considered valid.
@Future Specifies that the configuration property decorated with this annotation must have a date in the future. Now is defined as the current time according to the virtual machine. The calendar is used if the compared type is of type Calendar and the calendar is based on the current timezone and the current locale. Supported value types are java.util.Date, java.util.Calendar. Null elements are considered valid.
@Pattern Specifies that the configuration property decorated with this annotation must match the following regular expression. The regular expression follows the Java regular expression conventions java.util.regex.Pattern. Supported type value is String. Null elements are considered valid.

Troubleshoot bean validation in RAR modules
Bean validation troubleshooting tips
Bean validation in RAR modules
Bean Validation

+

Search Tips   |   Advanced Search