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,BigIntegerString,byteshortintlongand 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,BigIntegerString,byteshortintlongand 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,BigIntegerString,byteshortintlongand the respective wrappers of the primitive types. Check whether the property is a number having up to integerdigits and fraction fractional digits. Define column precision and scale.
@Email 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.Dateandjava.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 maxincluded. none
@Max yes field/property. Supported types are BigDecimal,BigIntegerString,byteshortintlongand 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,BigIntegerString,byteshortintlongand 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.Dateandjava.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,BigIntegerString,byteshortintlongand 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 StringCollection,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相关推荐

  1. 自定义hibernate validation注解

    效果和优点 先看最后效果: public class UserEntity {@Password private String password;@Emailprivate String email; ...

  2. Spring Boot 后台验证 Hibernate Validation

    后台验证详解 开发项目过程中,后台在很多地方需要进行校验操作,比如:前台表单提交,调用系统接口,数据传输等.而现在多数项目都采用MVC分层式设计,每层都需要进行相应地校验. 针对这个问题, JCP 出 ...

  3. Hibernate Validation校验注解详解

    在前后端传递数据的时候,往往后端需要校验传递数据的格式,比如用户名的格式,密码是否为空.我们可以在service层编写代码判断,但是当我们在多处需要校验传递来的数据的时候,就会出现大量重复的代码,一旦 ...

  4. Hibernate Validation与Spring整合各注解的用法Demo

    转自:https://www.aliyun.com/jiaocheng/1315650.html <dependency> <groupId>org.hibernate< ...

  5. 学习Spring Boot:(十)使用hibernate validation完成数据后端校验

    前言 后台数据的校验也是开发中比较注重的一点,用来校验数据的正确性,以免一些非法的数据破坏系统,或者进入数据库,造成数据污染,由于数据检验可能应用到很多层面,所以系统对数据校验要求比较严格且追求可变性 ...

  6. JSR 303 - Bean Validation与Hibernate Validation 介绍

    一.介绍 在应用程序中,通过使用 Bean Validation 或是你自己定义的 constraint,例如 @NotNull, @Max, @ZipCode, 就可以确保数据模型(JavaBean ...

  7. Hibernate Validation各注解的用法

    Hibernate Validator 是 Bean Validation 的参考实现 . Hibernate Validator 提供了 JSR 303 规范中所有内置 constraint 的实现 ...

  8. Spring Validation最佳实践及其实现原理,参数校验没那么简单!

    点击上方"方志朋",选择"设为星标" 回复"666"获取新整理的面试文章 作者:六点半起床 juejin.im/post/685654110 ...

  9. Spring Validation 最佳实践及其实现原理,参数校验没那么简单!

    之前也写过一篇关于Spring Validation使用的文章,不过自我感觉还是浮于表面,本次打算彻底搞懂Spring Validation.本文会详细介绍Spring Validation各种场景下 ...

最新文章

  1. 妈妈再也不担心我面试被 Redis 问得脸都绿了
  2. Python成长笔记 - 基础篇 (六)python模块
  3. java node websocket_nodejs怎么实现webSocket接口即时通讯服务?
  4. 【ICCV2019】完整论文列表
  5. VMware workstation9 Virtual Machine Network
  6. 【Verilog】verilog实现奇数次分频
  7. 隐马尔可夫的知识要点
  8. CISCO寄存器配置与说明
  9. hplus--H+ V2.3 (中文版)
  10. Arcgis使用教程(十)ARCGIS地图制图之统一修改地图符号样式的边框
  11. Java高阶知识体系总结(一)
  12. switch 大气层双系统 进入破解系统 及安装nsp nsz 格式教程
  13. 第四讲 移动互联网接入技术
  14. openfoam学习心得---牛顿流体相关公式理解、转换与整理
  15. falcon-agent模块代码里执行sys.CmdOutBytes命令导致的问题
  16. Your local changes to the following files would be overwritten by merge
  17. 最基础的python语法
  18. [网络安全自学篇] 十六.Python攻防之弱口令、自定义字典生成及网站暴库防护
  19. 水利水电课程指导之建筑制图基础_第二章测试试题
  20. 敏捷转型行动笔记:用户故事实践

热门文章

  1. python 基础命令-python常用命令有哪些
  2. python pandas读取excel-python pandas模块简单使用(读取excel为例)
  3. python3安装-Python3的安装
  4. python基础代码-python基础代码
  5. python基本语法-Python语法基础50题
  6. python语言有什么用-为什么现在很多人都使用Python语言有什么优势
  7. python3.6.4安装教程-centos7中安装python3.6.4的教程
  8. python处理数据的优势-Python处理excel的优点
  9. python爬虫实例100-Python 练习实例1
  10. python中是干嘛的-python中def是做什么的