jsr303 参考表
下面是主要的验证注解及说明:
注解 |
适用的数据类型 |
说明 |
@AssertFalse |
Boolean, boolean |
验证注解的元素值是false |
@AssertTrue |
Boolean, boolean |
验证注解的元素值是true |
@DecimalMax(value=x) |
BigDecimal, BigInteger, String, byte,short, int, long and the respective wrappers of the primitive types. Additionally supported by HV: any sub-type of Number andCharSequence. |
验证注解的元素值小于等于@ DecimalMax指定的value值 |
@DecimalMin(value=x) |
BigDecimal, BigInteger, String, byte,short, int, long and the respective wrappers of the primitive types. Additionally supported by HV: any sub-type of Number andCharSequence. |
验证注解的元素值小于等于@ DecimalMin指定的value值 |
@Digits(integer=整数位数, fraction=小数位数) |
BigDecimal, BigInteger, String, byte,short, int, long and the respective wrappers of the primitive types. Additionally supported by HV: any sub-type of Number andCharSequence. |
验证注解的元素值的整数位数和小数位数上限 |
@Future |
java.util.Date, java.util.Calendar; Additionally supported by HV, if theJoda Time date/time API is on the class path: any implementations ofReadablePartial andReadableInstant. |
验证注解的元素值(日期类型)比当前时间晚 |
@Max(value=x) |
BigDecimal, BigInteger, byte, short,int, long and the respective wrappers of the primitive types. Additionally supported by HV: any sub-type ofCharSequence (the numeric value represented by the character sequence is evaluated), any sub-type of Number. |
验证注解的元素值小于等于@Max指定的value值 |
@Min(value=x) |
BigDecimal, BigInteger, byte, short,int, long and the respective wrappers of the primitive types. Additionally supported by HV: any sub-type of CharSequence (the numeric value represented by the char sequence is evaluated), any sub-type of Number. |
验证注解的元素值大于等于@Min指定的value值 |
@NotNull |
Any type |
验证注解的元素值不是null |
@Null |
Any type |
验证注解的元素值是null |
@Past |
java.util.Date, java.util.Calendar; Additionally supported by HV, if theJoda Time date/time API is on the class path: any implementations ofReadablePartial andReadableInstant. |
验证注解的元素值(日期类型)比当前时间早 |
@Pattern(regex=正则表达式, flag=) |
String. Additionally supported by HV: any sub-type of CharSequence. |
验证注解的元素值与指定的正则表达式匹配 |
@Size(min=最小值, max=最大值) |
String, Collection, Map and arrays. Additionally supported by HV: any sub-type of CharSequence. |
验证注解的元素值的在min和max(包含)指定区间之内,如字符长度、集合大小 |
@Valid |
Any non-primitive type(引用类型) |
验证关联的对象,如账户对象里有一个订单对象,指定验证订单对象 |
@NotEmpty |
|
验证注解的元素值不为null且不为空(字符串长度不为0、集合大小不为0) |
@Range(min=最小值, max=最大值) |
|
验证注解的元素值在最小值和最大值之间 |
@NotBlank |
|
验证注解的元素值不为空(不为null、去除首位空格后长度为0),不同于@NotEmpty,@NotBlank只应用于字符串且在比较时会去除字符串的空格 |
@Length(min=下限, max=上限) |
|
验证注解的元素值长度在min和max区间内 |
|
|
验证注解的元素值是Email,也可以通过正则表达式和flag指定自定义的email格式 |
jsr303 参考表的更多相关文章
- ABAP 数据字典中的参考表和参考字段的作用
ABAP数据字典中的参考表和参考字段的作用 大家最初在SE11中创建表和结构的时候都会遇到一个问题,如果设定了某个字段为QUAN或者CURR类型,也就是数量或金额的时候,总会要求输入一个参考 ...
- spring mvc 使用jsr-303进行表单验证的方法介绍
源代码来源:http://howtodoinjava.com/spring/spring-mvc/spring-bean-validation-example-with-jsr-303-annotat ...
- 【转】蛋糕尺寸(寸)、尺寸(CM)、重量(磅)、食用人数对照换算参考表
转自:https://www.douban.com/note/324832054/ 蛋糕尺寸(寸).尺寸(CM).重量(磅).食用人数对照换算参考表 馋嘴猫DIY烘焙 2014-01-04 12:15 ...
- 东京区域2012-2014主要消费产品价格参考表——Excel
声明: 1.本表格数据取自<日本の統計 2016>: 2.本表所有价格单位为人民币,其日元均以当年平均汇率兑换为此人民币价格: 3.其人民币—日元年均汇率数据取自IMF Data Exch ...
- 通用权限管理系统数据字典 V3.9 版本,欢迎开发个各种业务系统的朋友们,参考表结构
C#.NET通用权限管理系统组件数据字典 导 航 ◇ (01) BaseItemDetails ◇ (02) BaseItems ◇ (03) BaseLog ◇ (04) BaseMessage ...
- app 图标规格参考表
转自:http://www.cocoachina.com/appstore/top/2012/1105/5031.html 像我一样记不住iOS应用图标像素尺寸的开发者不在少数,我经常需要查询不同设备 ...
- mongoDB 类型参考表
$type操作符是基于BSON类型来检索集合中匹配的数据类型,并返回结果. MongoDB 中可以使用的类型如下表所示: 参考资料:http://www.runoob.com/mongodb/mong ...
- Ubuntu - Dconf 注册表键值修改参考表
gsettings reset org.gnome.desktop.wm.preferences theme默认gnomegsettings set org.gnome.desktop.interfa ...
- 【转载】RPG颜色参考表
https://blog.csdn.net/a949308398/article/details/17013087
随机推荐
- 洛谷P1613 跑路 图论
正解:倍增+图论 解题报告: 传送门! 话说这题是真滴很妙啊,,,大概港下QwQ 首先看懂这道题,它是说,只要是1<<k的都能1s跑过,而且每条边的长度都是1,就是说一秒可以跑过1< ...
- loki之内存池SmallObj[原创]
loki库之内存池SmallObj 介绍 loki库的内存池实现主要在文件smallobj中,顾名思义它的优势主要在小对象的分配与释放上,loki库是基于策略的方法实现的,简单的说就是把某个类通过模板 ...
- 详解maxlength属性在textarea里奇怪的表现
这篇文章主要介绍了maxlength属性在textarea里奇怪的表现的相关资料,需要的朋友可以参考下 HTML5给表单带来了很多改变,比如今天要说的maxlength,这个属性可以限制输入框输入的最 ...
- cocos2d首印象
一. 创建工程 从 2.1.4 版本开始,官方就不再为 VS 提供模板了,逐步在各平台采用统一的 Python 脚本创建跨平台工程. 要创建工程,我们需要先从命令行进入 tools/project-c ...
- mysql数据库建模Navicat
用Navicat制作ER图及与SQL互相转化 http://wangbaiyuan.cn/sql-and-use-navicat-to-make-er-diagram-and-interactive. ...
- Java基础方法
1:读取resource下面的文件 ClassPathResource cpr = new ClassPathResource("./MyBatisXmlFile"); File ...
- 用Python实现的数据结构与算法:双端队列
一.概述 双端队列(deque,全名double-ended queue)是一种具有队列和栈性质的线性数据结构.双端队列也拥有两端:队首(front).队尾(rear),但与队列不同的是,插入操作在两 ...
- Django 基础篇章
Django 紧紧地遵循这种 MVC 模式,可以称得上是一种 MVC 框架. 以下是 Django 中 M.V 和 C 各自的含义: M ,数据存取部分,由django数据库层处理. V ,选择显示哪 ...
- vue-router的hash模式与history模式的对比
Vue-router 中hash模式和history模式的关系在vue的路由配置中有mode选项 最直观的区别就是在url中 hash 带了一个很丑的 # 而history是没有#的mode:&quo ...
- Python tricks(1) -- 动态定义一个新变量
python是动态语言, 无需声明变量即可使用. 传递一个tuple, list或者dict等等方式, 有时候这种方式的使用不是很好. 对于tuple和list来说都是用下标的访问方式(即使用[]), ...