Hibernate Validation Notes

Source: Internet
Author: User
Tags valid email address

@AssertTrue//For the Boolean field, the field can only be true @AssertFalse//The value of the field can only be false @CreditCardNumber//a rough verification of the credit card number @DecimalMax/   /can only be less than or equal to the value @DecimalMin//can only be greater than or equal to the value @Digits (integer= 2, fraction= 20)//Check whether it is a number of integers, fractions, decimal digits. @Email//Check if it is a valid Email address @Future//Check whether the date of the field is a future date @Length (min=,max=)//Check whether the length of the field to which it belongs is between Min and Max, only for strings @Max// The value of the field can only be less than or equal to the value @Min//The field's value can only be greater than or equal to the value @NotNull//cannot be null @NotBlank//cannot be empty, the check will ignore the space @NotEmpty//cannot be empty, where null is the empty string @ NULL//Check that the field is empty @Past//the date in which the field was checked is in the past @Size (min=, max=)//Check if the Size of the field is between Min and Max, which can be a string, array, collection, map, and so on @URL (protocol=,ho St,port)//Check if it is a valid URL, and if Protocol,host is provided, the URL must also meet the conditions provided @Valid//The note is used whenever the field is a field that contains a collection of other objects or a map or array. Or the field is a reference to a different object directly,//so that the object referenced by the field is checked as well as the current object

Here are the categories
Built-in constraint in Bean Validation

@Null The annotated element must be Null
@NotNull annotated element must not be null
@AssertTrue The annotated element must be true
@AssertFalse The annotated element must be false
@Min (value) The annotated element must be a number whose value must be greater than or equal to the specified minimum value
@Max (value) The annotated element must be a number whose value must be less than or equal to the specified maximum value
@DecimalMin (value) The annotated element must be a number whose value must be greater than or equal to the specified minimum value
@DecimalMax (value) The annotated element must be a number whose value must be less than or equal to the specified maximum value
@Size (max=, min=) the size of the annotated element must be within the specified range
@Digits (integer, fraction) The annotated element must be a number whose value must be within an acceptable range
@Past The annotated element must be a past date
@Future The annotated element must be a future date
@Pattern (regex=,flag=) The annotated element must conform to the specified regular expression

Hibernate Validator Additional constraint
@NotBlank (message =) validation string is not null and must be longer than 0
@Email The annotated element must be an e-mail address
@Length (min=,max=) The size of the annotated string must be within the specified range
@NotEmpty The annotated string must be non-empty
@Range (min=,max=,message=) The annotated element must be within the appropriate range

Hibernate Validation Notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.