hibernate-validator- 註解

空檢查
 2 @Null       驗證對象是否爲null
 3 @NotNull    驗證對象是否不爲null, 沒法查檢長度爲0的字符串
 4 @NotBlank 檢查約束字符串是否是Null還有被Trim的長度是否大於0,只對字符串,且會去掉先後空格.
 5 @NotEmpty 檢查約束元素是否爲NULL或者是EMPTY.
 6  
 7 Booelan檢查
 8 @AssertTrue     驗證 Boolean 對象是否爲 true  
 9 @AssertFalse    驗證 Boolean 對象是否爲 false  
10  
11 長度檢查
12 @Size(min=, max=) 驗證對象(Array,Collection,Map,String)長度是否在給定的範圍以內  
13 @Length(min=, max=) Validates that the annotated string is between min and max included.
14  
15 日期檢查
16 @Past           驗證 Date 和 Calendar 對象是否在當前時間以前  
17 @Future     驗證 Date 和 Calendar 對象是否在當前時間以後  
18 @Pattern    驗證 String 對象是否符合正則表達式的規則
19  
20 數值檢查,建議使用在Stirng,Integer類型,不建議使用在int類型上,由於表單值爲「」時沒法轉換爲int,但能夠轉換爲Stirng爲"",Integer爲null
21 @Min            驗證 Number 和 String 對象是否大等於指定的值  
22 @Max            驗證 Number 和 String 對象是否小等於指定的值  
23 @DecimalMax 被標註的值必須不大於約束中指定的最大值. 這個約束的參數是一個經過BigDecimal定義的最大值的字符串表示.小數存在精度
24 @DecimalMin 被標註的值必須不小於約束中指定的最小值. 這個約束的參數是一個經過BigDecimal定義的最小值的字符串表示.小數存在精度
25 @Digits     驗證 Number 和 String 的構成是否合法  
26 @Digits(integer=,fraction=) 驗證字符串是不是符合指定格式的數字,interger指定整數精度,fraction指定小數精度。
27  
28 @Range(min=, max=) Checks whether the annotated value lies between (inclusive) the specified minimum and maximum.
29 @Range(min=10000,max=50000,message="range.bean.wage")
30 private BigDecimal wage;
31  
32 @Valid 遞歸的對關聯對象進行校驗, 若是關聯對象是個集合或者數組,那麼對其中的元素進行遞歸校驗,若是是一個map,則對其中的值部分進行校驗.(是否進行遞歸驗證)
33 @CreditCardNumber信用卡驗證
34 @Email  驗證是不是郵件地址,若是爲null,不進行驗證,算經過驗證。
35 @ScriptAssert(lang= ,script=, alias=)
36 @URL(protocol=,host=, port=,regexp=, flags=)
相關文章
相關標籤/搜索