Hibernate Validation注解列表
下面是主要的验证注解及说明:
注解 |
适用的数据类型 |
说明 |
@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格式 |
Hibernate Validation注解列表的更多相关文章
- Hibernate validation 注解 springmvc 验证 分组
SpringMVC验证框架Validation特殊用法 1. 分组 有的时候,我们对一个实体类需要有多中验证方式,在不同的情况下使用不同验证方式,比如说对于一个实体类来的id来说,保存的时候是不需 ...
- Spring Boot Validation,既有注解不满足,我是怎么暴力扩展validation注解的
前言 昨天,我开发的代码,又收获了一个bug,说是界面上列表查询时,正常情况下,可以根据某个关键字keyword模糊查询,后台会去数据库 %keyword%查询(非互联网项目,没有使用es,只能这样了 ...
- Hibernate Validation使用示例及讲解
Hibernate Validation使用示例及讲解 时间 -- :: ITeye-博客 原文 http://wdmcygah.iteye.com/blog/2174680 主题 Java 在项目开 ...
- Spring Boot 系列教程19-后台验证-Hibernate Validation
后台验证 开发项目过程中,后台在很多地方需要进行校验操作,比如:前台表单提交,调用系统接口,数据传输等.而现在多数项目都采用MVC分层式设计,每层都需要进行相应地校验. 针对这个问题, JCP 出台一 ...
- JSR303/JSR-349,hibernate validation,spring validation 之间的关系
JSR303是一项标准,JSR-349是其的升级版本,添加了一些新特性,他们规定一些校验规范即校验注解,如@Null,@NotNull,@Pattern,他们位于javax.validation.co ...
- spring-boot 使用hibernate validation对参数进行优雅的校验
springboot天生支持使用hibernate validation对参数的优雅校验,如果不使用它,只能对参数挨个进行如下方式的手工校验,不仅难看,使用起来还很不方便: if(StringUtil ...
- Java、Hibernate(JPA)注解大全
1.@Entity(name=”EntityName”) 必须,name为可选,对应数据库中一的个表 2.@Table(name=””,catalog=””,schema=””) 可选,通常和@Ent ...
- hibernate annotation注解方式来处理映射关系
在hibernate中,通常配置对象关系映射关系有两种,一种是基于xml的方式,另一种是基于annotation的注解方式,熟话说,萝卜青菜,可有所爱,每个人都有自己喜欢的配置方式,我在试了这两种方式 ...
- 批量产生ssh2项目中hibernate带注解的pojo类的快捷方法
近几个月一直在忙于项目组的ios应用项目的开发,没有太多时间去研究web应用方面的问题了.刚好,昨天有网友问到如何批量产生hibernate带注解的pojo类的快捷方法,所谓批量就是指将当前数据库中所 ...
随机推荐
- 创建被访问的swf文件
首先创建一个fla文件,名字叫movie.fla,在该文件库中放一个mc, 并将其拖放到舞台上,然后 命名为test_mc, 然后在库中给该mc绑定一个类,类名随意. 创建访问swf文件的swf文件 ...
- Speex for Android
http://blog.csdn.net/chenfeng0104/article/details/7088138在Android开发中,需要录音并发送到对方设备上.这时问题来了,手机常会是GPRS. ...
- Win7系统下利用U盘安装Ubuntu14.04麒麟版
转自http://www.360doc.cn/article/14743053_335473181.html 重要提示:在采用u盘安装ubuntu分区时,所有磁盘一定要全部设置成逻辑分区,包括根目录/ ...
- Windows PE3.0制作方法(从Win7中提取制作)
Windows PE3.0制作方法(从Win7中提取制作 在d:新建文件夹winpe,在winpe中新建sources.pe3和new文件夹,把附件中提供的工具imagex连文件夹一起放到winpe目 ...
- jsp转发action的问题找不到acton
-----------------------------jsp转发action的问题找不到acton------------------------------------------- jsp: ...
- M站 滚动日历弹框
先放张效果图: 完整Demo: <!DOCTYPE html> <html lang="en"> <head> <meta http-eq ...
- sql 无法识别的配置节 system.serviceModel
sql 链接实例的时候,提示 无法识别的配置节 system.serviceModelC:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\mac ...
- STL中vector容器实现反转(reverse)
vector容器中实现可以通过以下两种方式实现: #include "stdafx.h" #include <vector> #include <iostream ...
- Firefox插件一键切换兼容IE
转载:http://mozilla.com.cn/thread-42137-1-1.html 让火狐兼容IE的双核扩展,一键切换至IE内核,网银支付无忧愁.支持Adblock plus和FireGes ...
- js查看浏览器类型和版本
var Sys = {}; var ua = navigator.userAgent.toLowerCase(); var s; var scan; (s = ua.match(/msie ([\d. ...