Hibernate validation annonation
https://docs.jboss.org/hibernate/validator/4.0.1/reference/en/html_single/
另参见
http://docs.oracle.com/javaee/7/api/javax/validation/constraints/package-summary.html
Annotation | Part of Bean Validation Specification | Apply on | Use | Hibernate Metadata impact |
---|---|---|---|---|
@AssertFalse | yes | field/property |
check that the annotated element is false .
|
none |
@AssertTrue | yes | field/property |
check that the annotated element is true .
|
none |
@DecimalMax | yes |
field/property. Supported types are BigDecimal ,BigInteger , String ,byte , short , int , long and the respective wrappers of the primitive types.
|
The annotated element must be a number whose value must be lower or equal to the specified maximum. The parameter value is the string representation of the max value according to theBigDecimal string representation.
|
none |
@DecimalMin | yes |
field/property. Supported types are BigDecimal ,BigInteger , String ,byte , short , int , long and the respective wrappers of the primitive types.
|
The annotated element must be a number whose value must be higher or equal to the specified minimum. The parameter value is the string representation of the min value according to theBigDecimal string representation.
|
none |
@Digits(integer=, fraction=) | yes |
field/property. Supported types are BigDecimal ,BigInteger , String ,byte , short , int , long and the respective wrappers of the primitive types.
|
Check whether the property is a number having up to integer digits and fraction fractional digits.
|
Define column precision and scale. |
no | field/property. Needs to be a string. | Check whether the specified string is a valid email address. | none | |
@Future | yes |
field/property. Supported types are java.util.Date andjava.util.Calendar .
|
Checks whether the annotated date is in the future. | none |
@Length(min=, max=) | no | field/property. Needs to be a string. |
Validate that the annotated string is between min and max included.
|
none |
@Max | yes |
field/property. Supported types are BigDecimal ,BigInteger , String ,byte , short , int , long and the respective wrappers of the primitive types.
|
Checks whether the annotated value is less than or equal to the specified maximum. | Add a check constraint on the column. |
@Min | yes |
field/property. Supported types are BigDecimal ,BigInteger , String ,byte , short , int , long and the respective wrappers of the primitive types.
|
Check whether the annotated value is higher than or equal to the specified minimum. | Add a check constraint on the column. |
@NotNull | yes | field/property |
Check that the annotated value is not null.
|
Column(s) are not null. |
@NotEmpty | no | field/property. Needs to be a string. |
Check if the string is not null nor empty.
|
none |
@Null | yes | field/property |
Check that the annotated value is null.
|
none |
@Past | yes |
field/property. Supported types are java.util.Date andjava.util.Calendar .
|
Checks whether the annotated date is in the past. | none |
@Pattern(regex=, flag=) | yes | field/property. Needs to be a string. |
Check if the annotated string match the regular expressionregex .
|
none |
@Range(min=, max=) | no |
field/property. Supported types are BigDecimal ,BigInteger , String ,byte , short , int , long and the respective wrappers of the primitive types.
|
Check whether the annotated value lies between (inclusive) the specified minimum and maximum. | none |
@Size(min=, max=) | yes |
field/property. Supported types are String , Collection ,Map and arrays .
|
Check if the annotated element size is between min and max (inclusive). | Column length will be set to max. |
@Valid | yes | field/property | Perform validation recursively on the associated object. | none |
Hibernate validation annonation相关推荐
- 自定义hibernate validation注解
效果和优点 先看最后效果: public class UserEntity {@Password private String password;@Emailprivate String email; ...
- Spring Boot 后台验证 Hibernate Validation
后台验证详解 开发项目过程中,后台在很多地方需要进行校验操作,比如:前台表单提交,调用系统接口,数据传输等.而现在多数项目都采用MVC分层式设计,每层都需要进行相应地校验. 针对这个问题, JCP 出 ...
- Hibernate Validation校验注解详解
在前后端传递数据的时候,往往后端需要校验传递数据的格式,比如用户名的格式,密码是否为空.我们可以在service层编写代码判断,但是当我们在多处需要校验传递来的数据的时候,就会出现大量重复的代码,一旦 ...
- Hibernate Validation与Spring整合各注解的用法Demo
转自:https://www.aliyun.com/jiaocheng/1315650.html <dependency> <groupId>org.hibernate< ...
- 学习Spring Boot:(十)使用hibernate validation完成数据后端校验
前言 后台数据的校验也是开发中比较注重的一点,用来校验数据的正确性,以免一些非法的数据破坏系统,或者进入数据库,造成数据污染,由于数据检验可能应用到很多层面,所以系统对数据校验要求比较严格且追求可变性 ...
- JSR 303 - Bean Validation与Hibernate Validation 介绍
一.介绍 在应用程序中,通过使用 Bean Validation 或是你自己定义的 constraint,例如 @NotNull, @Max, @ZipCode, 就可以确保数据模型(JavaBean ...
- Hibernate Validation各注解的用法
Hibernate Validator 是 Bean Validation 的参考实现 . Hibernate Validator 提供了 JSR 303 规范中所有内置 constraint 的实现 ...
- Spring Validation最佳实践及其实现原理,参数校验没那么简单!
点击上方"方志朋",选择"设为星标" 回复"666"获取新整理的面试文章 作者:六点半起床 juejin.im/post/685654110 ...
- Spring Validation 最佳实践及其实现原理,参数校验没那么简单!
之前也写过一篇关于Spring Validation使用的文章,不过自我感觉还是浮于表面,本次打算彻底搞懂Spring Validation.本文会详细介绍Spring Validation各种场景下 ...
最新文章
- php读取access编码格式,php+access如何设置编码格式
- 区块链学习之密码学安全技术(五)
- python数据生成正态分布图_Python 与金融数据生成机器学习的特征数据
- 最大流EK和Dinic算法
- 51cto 检测ip地址冲突_在Linux中发现IP地址冲突的方法
- ios中navigationItem的titleView如何居中
- 几步教你用 Python 制作一个 RPA 机器人!
- java环境变量的设置方法_Java环境变量配置方法详解
- 网易2017笔试 编程题目
- python sklearn库 rnn_scikit-learn 逻辑回归类库使用小结
- 基于LSTM算法的股票预测详解
- http/https/浏览器
- K - Assigning Frequencies
- 在网络上共享条码打印机
- linux 扩展pam支持第三方认证
- TIME_WAIT状态存在的意义
- VR购物丨抢占电商流量新阵地
- 百度文库推出“文源计划”
- 魔改版本xposed(arm,arm64,x86,x86_64)支持雷电,逍遥等模拟器
- 龙套生涯:《鬼马双星》——许冠杰大战洪金宝
热门文章
- python3入门-终于懂得python3快速入门教程
- python贴吧发帖脚本-分享用Python写的99收抢单小脚本,仅供学习
- 怎么自学python语言-怎样学好python
- python开发的软件sparrow-sparrow
- python3.8.2安装教程-Python3.8.2 软件介绍(附安装包)
- python手机版下载苹果版-Pyto-Python3
- python工程师薪资坑吗-Python中反人类直觉的特性,你踩过坑吗?
- python快速入门答案-Python 快速入门笔记(1):简介
- windows或Ubuntu中请求github.com请求超时,或在下载GitHub文件出现:<urlopen error [Errno 110] Connection timed out>
- python实现全景图片拼接