Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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

AssertFalse

The Annotated Element must be false.

AssertFalse.List

Defines several AssertFalse annotations on the same element.

AssertTrue

The Annotated Element must be true.

AssertTrue.List

Defines several AssertTrue annotations on the same element.

DecimalMax

The annotated element must be a number whose value must be lower or equal to the specified maximum.

DecimalMax.List

Defines several DecimalMax annotations on the same element.

DecimalMin

The annotated element must be a number whose value must be higher or equal to the specified minimum.

DecimalMin.List

Defines several DecimalMin annotations on the same element.

Digits

The annotated element must be a number within accepted range Supported types are: BigDecimal BigInteger CharSequence byteshortintlong, and their respective wrapper types

Digits.List

Defines several Digits annotations on the same element.

Email

The string has to be a well-formed email address.

Email.List

Defines several @Email constraints on the same element.

Future

The annotated element must be an instant, date or time in the future.

Future.List

Defines several Future annotations on the same element.

FutureOrPresent

The annotated element must be an instant, date or time in the present or in the future.

FutureOrPresent.List

Defines several FutureOrPresent annotations on the same element.

Max

The annotated element must be a number whose value must be lower or equal to the specified maximum.

Max.List

Defines several Max annotations on the same element.

Min

The annotated element must be a number whose value must be higher or equal to the specified minimum.

Min.List

Defines several Min annotations on the same element.

Negative

The annotated element must be a strictly negative number (i.e.

Negative.List

Defines several Negative constraints on the same element.

NegativeOrZero

The annotated element must be a negative number or 0.

NegativeOrZero.List

Defines several NegativeOrZero constraints on the same element.

NotBlank

The annotated element must not be null and must contain at least one non-whitespace character.

NotBlank.List

Defines several @NotBlank constraints on the same element.

NotEmpty

The annotated element must not be null nor empty.

NotEmpty.List

Defines several @NotEmpty constraints on the same element.

NotNull

The annotated element must not be null.

NotNull.List

Defines several NotNull annotations on the same element.

Null

The annotated element must be null.

Null.List

Defines several Null annotations on the same element.

Past

The annotated element must be an instant, date or time in the past.

Past.List



This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Bean Validation: Built-in constraints

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×