hibernate_validator_08
内置的约束条件
Hibernate Validator包含了一些基本的使用比较广的约束,下面是一些Hibernate Validator给出的最常用的约束.另外Hibernate Validator还提供了一些有有的custom约束.
一.Bean Validation constraints
下面是一些常的constraints,它们的作用,支持的数据类型.它们全部都是属性级别的注释,如果你使用Hibernate 对象-关系映射,当你为你的model创建ddl时,有一些约束是要被考虑在内的.
注意:Hibernate Validator的有些约束是能支持比Bean Validation specification要求的数据类型的更多的类型.e.g. @Max can be applied to Strings
| Annotation |
Supported data types |
作用 | Hibernate metadata impact |
| @AssertFalse | Boolean , boolean |
Checks that the |
没有 |
| @AssertTrue | Boolean , boolean |
Checks that the |
没有 |
| @DecimalMax |
BigDecimal , of Number and |
被标注的值必须 |
没有 |
| @DecimalMin |
BigDecimal , |
被标注的值必须 |
没有 |
|
@Digits(integer=, |
BigDecimal , |
Checks whether the |
对应的数据库表 |
|
@Future |
java.util.Date , |
检查给定的日期是否 |
没有 |
| @Max |
BigDecimal , |
检查该值是否大于或 |
会给对应的数据库表 |
| @Min |
BigDecimal , |
检查该值是否大于或 |
的最小值. |
| @NotNull | Any type |
Checks that the |
对应的表字段不允许 |
| @Null | Any type |
Checks that the |
没有 |
| @Past |
java.util.Date , of ReadablePartial |
检查标注对象中的值 |
没有 |
|
@Pattern(regex=, |
String . Additionally |
检查该字符串是否能 |
没有 |
| @Size(min=, max=) |
String , Collection , |
Checks if the |
对应的数据库表字段 |
| @Valid |
Any non-primitive |
递归的对关联对象进 |
没有 |
| 注意: 这些约束都能支持message,groups,payload的参数 | |||
二,Additional constraints
除了Bean Validation API Hibernate Validator中的约束外,还有一些有用的定制的约束.其中@ScriptAssert是一个类级别的注释
| Annotation |
Supported data |
作用 |
Hibernate metadata |
| @CreditCardNumber | CharSequence |
Checks that the test. Note, this |
没有 |
| CharSequence |
Checks whether the |
没有 | |
| @Length(min=, max=) | CharSequence |
Validates that |
对应的数据库表字段 |
|
@ModCheck(modType=, |
CharSequence |
Checks that the multiplier |
没有 |
| @NotBlank | CharSequence |
Checks that the whitespaces are |
没有 |
| @NotEmpty |
CharSequence , |
Checks whether the |
没有 |
| @Range(min=, max=) |
BigDecimal , |
Checks whether |
没有 |
|
@SafeHtml(whitelistType=, |
CharSequence |
Checks whether |
没有 |
|
@ScriptAssert(lang=, |
Any type |
Checks whether the element. In |
没有 |
|
@URL(protocol=, |
CharSequence |
Checks if the which the URL must |
没有 |
三, Country specific constraints(略)
hibernate_validator_08的更多相关文章
随机推荐
- github 托管代码两分钟教程【转载,亲测可行】
http://blog.csdn.net/duxinfeng2010/article/details/8654690 出自以上地址 本篇文章介绍的是如何将工程代码托管到上面:如果你还没注册GitHub ...
- NXP LPC11xx I2C Slave 从机程序
/**************************************************************************** * $Id:: i2cslave.c 363 ...
- C#中实现邮件发送功能
public static int sendmail(string to, string body,string subject) { try { int nContain = 0; ///添加发件人 ...
- 【转】【Android】使用BaseAdapter实现复杂的ListView
原文网址:http://blog.csdn.net/jueblog/article/details/11857281 使用BaseAdapter实现复杂的ListView的步骤: 1. 数据你要准备好 ...
- (转载)PHP strtotime函数详解
(转载)http://www.jb51.net/article/21495.htm strtotime函数是一个很好的函数,灵活的运用它,会给你的工作带来不少方便.但PHP的手册中却对此函数的参数没作 ...
- 图论(A*算法,K短路) :POJ 2449 Remmarguts' Date
Remmarguts' Date Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 25216 Accepted: 6882 ...
- Fire Net(深搜 和一前不一样的深搜)
/* http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1162 本题妙处: 用一个数对行取商是 ...
- Big Event in HDU(01背包)
/* 题意: 输入一个数n代表有n种物品, 接下来输入物品的价值和物品的个数: 然后将这些物品分成A B 两份,使A B的价值尽可能相等也就是尽量分的公平一些,如果无法使A B相等,那么就使A多一些: ...
- php 利用第三方软件进行网页快照
网页快照有很多方法,具体的大家可以百度下.这里我复制一位别人的. 这里我只说下利用第三方软件(Web2Pic_Pro)实现. (1). 下载web2pic_pro软件.下载地址 http://isha ...
- 饿了么 ---Java面试
下午去饿了么参加面试,其实也满怀期待,毕竟也是个大公司. 交通:偏外环,真北路 环境:感觉压抑,不通风,面试人很多,可能是屋子高度低,不舒服. 填了资料,等待面试,两轮,真是憋屈 都是搞技术的,何苦为 ...