当前位置:网站首页>Jrs-303 usage
Jrs-303 usage
2022-07-27 18:19:00 【StrugglingXuYang】
Data verification is used in the project , I searched the Internet for some information , Tidy up It's convenient for you to check
JRS-303 It is for data verification
Import dependence
<!--JSR-303 Data verification starts -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!--JSR-303 End of data verification -->
First, add @Validated annotation Here's the picture
@Validated
public class Collect implements Serializable {
private static final long serialVersionUID = 851224694046130732L;
The following are commonly used comments , Just mark above the field
Empty check
@Null Verify that the object is null
@NotNull Verify that the object is not null, Can't check length is 0 String
@NotBlank Check if the constraint string is Null And the Trim Is the length greater than 0, For strings only , And the space before and after will be removed .
@NotEmpty Check if the constraint element is NULL Or is it EMPTY.
Booelan Check
@AssertTrue verification Boolean Whether the object is true
@AssertFalse verification Boolean Whether the object is false
Length check
@Size(min=, max=) Verify the object (Array,Collection,Map,String) Is the length within the given range
@Length(min=, max=) Validates that the annotated string is between min and max included.
Date check
@Past verification Date and Calendar Whether the object is before the current time , If the verification is valid, the annotated element must be a past date
@Future verification Date and Calendar Whether the object is after the current time , If the validation is established, the annotated element must be a future date
@Pattern verification String Whether the object conforms to the rules of regular expression , The annotated element conforms to the formulated regular expression ,regexp: Regular expressions flags: Appoint Pattern.Flag Array of , Represents options related to regular expressions .
Numerical check
@Min verification Number and String Whether the object is large equal to the specified value
@Max verification Number and String Whether the object is small equal to the specified value
@DecimalMax The value to be annotated must not be greater than the maximum value specified in the constraint . The parameter of this constraint is a pass through BigDecimal String representation of the defined maximum value . Decimals have precision
@DecimalMin The labeled value must be no less than the minimum value specified in the constraint . The parameter of this constraint is a pass through BigDecimal The string representation of the minimum value defined . Decimals have precision
@Digits verification Number and String Whether the constitution of is legal
@Digits(integer=,fraction=) Verify that the string is a number in the specified format ,interger Specify integer precision ,fraction Specify decimal precision .
@Range(min=, max=) The specified element must be in the appropriate range
@Range(min=10000,max=50000,message=”range.bean.wage”)
@Email Verify that it's an email address , If null, No validation , Calculation passed verification .
边栏推荐
- 查找表中多余重复记录并删除保留最小一个
- Dbeaver connection MySQL error: the server time zone value 'Ö Ð¹ ú±ê ×¼ ʱ ¼ ä‘ is unrecognized or represents more than
- 发布自己的npm组件库
- 力压谷歌、英伟达!阿里含光800芯片再获权威测试世界第一
- 【学习笔记】数据库中锁的分类
- 国巨斥资18亿美元收购竞争对手Kemet,交易或在明年下半年完成
- 贴牌“美国制造”,国产安防设备竟被装上了美航母!
- Golang Chan implements mutual exclusion
- ES查询限制10000条数据解决方法
- Local development using LWC in salesforce
猜你喜欢
随机推荐
携手三星,vivo将推Exynos980双模5G手机!
Huawei mate30 Pro 5g disassembly: self developed chips account for more than half, and American chips still exist!
【学习笔记】lombok的@Builder注解
力压谷歌、英伟达!阿里含光800芯片再获权威测试世界第一
Interview FAQs 12
Knowledge dry goods: basic storage service novice Experience Camp
解决Reids不能被其他IP访问
How to solve the error of ora-00955 when Oracle modifies the primary key
美团二面:为什么Redis会有哨兵?
年终总结模板
深度学习-视频行为识别:论文阅读——双流网络(Two-stream convolutional networks for action recognition in videos)
The first PCIe 5.0 SSD master of Jiangsu Huacun: TSMC 12NM process, mass production in 2020
[learning notes] Lombok's @builder annotation
Mysql四种锁
OEM "made in the United States", domestic security equipment has been installed on the U.S. aircraft carrier!
江苏华存首发PCIe 5.0 SSD主控:台积电12nm工艺,2020年量产
同心向前,Google Play 十周年啦!
Class not found: “com.parkManagement.dao.DaoTest 测试找不到测试类
The latest advanced interview questions for big factories are necessary
Prevent SQL injection









