Sunday, 16 June 2019

Bean Validation: Built-in constraints


'javax.validation.constraints' package provides number of annotations to do validations on data.

Below table summarizes the annotations provided by JSR-380 specification.

Annotation
Description
The annotated element must be false.
Defines several AssertFalse annotations on the same element.
The annotated element must be true.
Defines several AssertTrue annotations on the same element.
The annotated element must be a number whose value must be lower or equal to the specified maximum.
Defines several DecimalMax annotations on the same element.
The annotated element must be a number whose value must be higher or equal to the specified minimum.
Defines several DecimalMin annotations on the same element.
The annotated element must be a number within accepted range Supported types are: BigDecimal BigInteger CharSequence byteshortintlong, and their respective wrapper types
Defines several Digits annotations on the same element.
The string has to be a well-formed email address.
Defines several @Email constraints on the same element.
The annotated element must be an instant, date or time in the future.
Defines several Future annotations on the same element.
The annotated element must be an instant, date or time in the present or in the future.
Defines several FutureOrPresent annotations on the same element.
The annotated element must be a number whose value must be lower or equal to the specified maximum.
Defines several Max annotations on the same element.
The annotated element must be a number whose value must be higher or equal to the specified minimum.
Defines several Min annotations on the same element.
The annotated element must be a strictly negative number (i.e.
Defines several Negative constraints on the same element.
The annotated element must be a negative number or 0.
Defines several NegativeOrZero constraints on the same element.
The annotated element must not be null and must contain at least one non-whitespace character.
Defines several @NotBlank constraints on the same element.
The annotated element must not be null nor empty.
Defines several @NotEmpty constraints on the same element.
The annotated element must not be null.
Defines several NotNull annotations on the same element.
The annotated element must be null.
Defines several Null annotations on the same element.
The annotated element must be an instant, date or time in the past.
Defines several Past annotations on the same element.
The annotated element must be an instant, date or time in the past or in the present.
Defines several PastOrPresent annotations on the same element.
The annotated CharSequence must match the specified regular expression.
Defines several Pattern annotations on the same element.
The annotated element must be a strictly positive number (i.e.
Defines several Positive constraints on the same element.
The annotated element must be a positive number or 0.
Defines several PositiveOrZero constraints on the same element.
The annotated element size must be between the specified boundaries (included).
Defines several Size annotations on the same element.




Previous                                                 Next                                                 Home

No comments:

Post a Comment