Annotation | Apply on | Runtime checking | Hibernate Metadata impact |
---|---|---|---|
@Length(min=, max=) | property (String) | check if the string length match the range | Column length will be set to max |
@Max(value=) | property (numeric or string representation of a numeric) | check if the value is less than or equals to max | Add a check constraint on the column |
@Min(value=) | property (numeric or string representation of a numeric) | check if the value is more than or equals to min | Add a check constraint on the column |
@NotNull | property | check if the value is not null | Column(s) are not null |
@NotEmpty | property | check if the string is not null nor empty. Check if the connection is not null nor empty | Column(s) are not null (for String) |
@Past | property (date or calendar) | check if the date is in the past | Add a check constraint on the column |
@Future | property (date or calendar) | check if the date is in the future | none |
@Pattern(regex="regexp", flag=) or @Patterns( {@Pattern(...)} ) | property (string) | check if the property match the regular expression given a match flag (see java.util.regex.Pattern ) | none |
@Range(min=, max=) | property (numeric or string representation of a numeric) | check if the value is between min and max (included) | Add a check constraint on the column |
@Size(min=, max=) | property (array, collection, map) | check if the element size is between min and max (included) | none |
@AssertFalse | property | check that the method evaluates to false (useful for constraints expressed in code rather than annotations) | none |
@AssertTrue | property | check that the method evaluates to true (useful for constraints expressed in code rather than annotations) | none |
@Valid | property (object) | perform validation recursively on the associated object. If the object is a Collection or an array, the elements are validated recursively. If the object is a Map, the value elements are validated recursively. | none |
property (String) | check whether the string is conform to the email address specification | none | |
@CreditCardNumber | property (String) | check whether the string is a well formated credit card number (derivative of the Luhn algorithm) | none |
@Digits | property (numeric or string representation of a numeric) | check whether the property is a number having up to integerDigits integer digits and fractionalDigits fractonal digits | define column precision and scale |
@EAN | property (string) | check whether the string is a properly formated EAN or UPC-A code | none |
hibernate validator用法
最新推荐文章于 2025-02-11 12:07:39 发布