Spring MVC Data Validation Framework annotations

Source: Internet
Author: User

@AssertFalse annotated element must be false
@AssertTrue annotated element must be false
@DecimalMax (value) The annotated element must be a number whose value must be less than or equal to the specified minimum value
@DecimalMin (value) The annotated element must be a number whose value must be greater than or equal to the specified minimum value
@Digits (integer=, fraction=) The annotated element must be a number whose value must be within an acceptable range
@Future The annotated element must be a date and check whether the given date is later than it is now.
@Max (value) The annotated element must be a number whose value must be less than or equal to the specified minimum value, and check whether the value is less than or equal to the maximum value specified in the constraint condition. A check constraint is added to the corresponding database table field.
@Min The annotated element must be a number whose value must be greater than or equal to the specified minimum value, and check whether the value is greater than or equal to the minimum value set in the constraint condition. A check constraint is added to the corresponding database table field.
@NotNull annotated element must not be null
@Null annotated element must be Null
@Past (Java.util.date/calendar); The annotated element must be past the date, and the value in the dimension object is checked to indicate that the date is earlier than the current.
The annotated element of the @Pattern (regex=, flag=) must conform to the regular expression to check whether the string matches the regex-defined regular expression in the case of match designation.
@Size (min=, max=) annotated element must be in the scope of the formulation (data type: String, Collection, Map and arrays)
The @Valid recursively verifies the associated object, and if the associated object is a collection or an array, the element is recursively checked, and if it is a map, the value part of it is verified.
@CreditCardNumber a rough verification of the credit card number
@Email The annotated element must be an electronic fuel tank address
@Length (min=, max=) The annotated object must be the size of the string must be within the scope of the formulation.
@NotBlank the annotated object must be a string, cannot be empty, and the space is ignored when checking
@NotEmpty Annotated object must be empty (data: string,collection,map,arrays)
@Range (min=, max=) The annotated element must be within the appropriate range (data: BigDecimal, BigInteger, String, Byte, short, int, long and the wrapper class of the original type)
@SafeHtml (whitelisttype=, additionaltags=) The annotated element checks whether the callout value contains a malicious fragment such as
@ScriptAssert (lang=, script=, alias=) any type, to use this constraint, you must first ensure that the Java Scripting API is the JSR 223 ("Scripting for the JAVATM Platform ") is implemented in the classpath. If you use Java 6, then it is not a problem, if the old version, then you need to add the implementation of JSR 223 into the classpath. An expression in this constraint can be written using any script that is compatible with JSR 223. (Please refer to Javadoc for more information)
@URL (protocol=, host=, port=, regexp=, flags=) The annotated object must be a string, check if it is a valid URL, and if Protocol,host is provided, the URL needs to meet the provided conditions

-----------------------Turn---------------------

Spring MVC Data Validation Framework annotations

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.