原文地址: https://www.cnblogs.com/nxzblogs/articles/13995569.html
@AssertFalse | bool | 元素必須是false | 否
@AssertTrue | bool | 元素必須是true | 否
@DecimalMax | Number的子類型(浮點數除外)以及String | 元素必須是一個數字,且值必須<=最大值 | 否
@DecimalMin | 同上 | 元素必須是一個數字,且值必須>=最大值 | 否
@Max | 同上 | 同上 | 否
@Min | 同上 | 同上 | 否
@Digits | 同上 | 元素構成是否合法(整數部分和小數部分) | 否
@Future | 時間類型(包括JSR310) | 元素必須爲一個將來(不包含相等)的日期(比較精確到毫秒) | 否
@Past | 同上 | 元素必須爲一個過去(不包含相等)的日期(比較精確到毫秒) | 否
@NotNull | any | 元素不能爲null | 是
@Null | any | 元素必須爲null | 是
@Pattern | 字符串 | 元素需符合指定的正則表達式 | 否
@Size | String/Collection/Map/Array | 元素大小需在指定範圍中 | 否
@Email | 字符串 | 元素必須爲電子郵箱地址 | 否
@NotEmpty | 容器類型 | 集合的Size必須大於0 | 是
@NotBlank | 字符串 | 字符串必須包含至少一個非空白的字符 | 是
@Positive | 數字類型 | 元素必須爲正數(不包括0) | 否
@PositiveOrZero | 同上 | 同上(包括0) | 否
@Negative | 同上 | 元素必須爲負數(不包括0) | 否
@NegativeOrZero | 同上 | 同上(包括0) | 否
@PastOrPresent | 時間類型 | 在@Past基礎上包括相等 | 否
@FutureOrPresent | 時間類型 | 在@Futrue基礎上包括相等 | 否
搜索
複製