当前位置:网站首页>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 .
边栏推荐
- Marvell announced the roadmap of its arm server chip, and the performance of the next generation will be twice that of thunderx2
- 使用分布式框架WCF出现的BUG记录
- Three consecutive high-frequency interview questions of redis online celebrity: cache penetration? Cache breakdown? Cache avalanche?
- XStream reports an error abstractreflectionconverter$unknownfield exception when parsing XML
- 邮件安全运营难?Coremail携手云商店打造企业邮箱办公新生态!
- Resolve merge fields in salesforce
- 又一个时代的终结!
- Set up SSO based on SAML 2.0 in salesforce and enable JIT user provisioning (between SF orgs / between SF org and experience cloud / other IDPs)
- 多线程导入数据并生成错误文件用redis存储
- SQL Server连接到服务器无效的解决办法
猜你喜欢

超实用!阿里P9私藏的Kubernetes学习笔记,看完直呼NB

数据库的常用命令2

3. opencv几何变换

2. 改变颜色空间及颜色检测

vue使用keep-alive实现页面缓存

What every Salesforce developer should know about Dates and Times in Apex

Understand │ what is cross domain? How to solve cross domain problems?

深度学习:GCN图分类案例

Exciting collection of new features released by salesforce

【学习笔记】Redis中有序集合zset的实现原理——跳表
随机推荐
The latest advanced interview questions for big factories are necessary
动态链表2栈的链表存储结构(LinkedStack实现)
GIS数据漫谈(五)— 地理坐标系统
golang 等待一组goroutine完成,并带返回值(2)
同心向前,Google Play 十周年啦!
MySQL creates a student table and queries grades
On recommend mechanism in distributed training
Salesforce certified sharing and visibility Designer (su20) certification examination summary
《华为是谁》纪录短片集登陆BBC:曝光大量任正非不为人知经历
Knowledge dry goods: basic storage service novice Experience Camp
org.gradle.api.UncheckedIOException: Could not load properties for module ‘gradle-kotlin-dsl‘ from C
Bug records using distributed framework WCF
Salesforce runs all test classes and gets coverage reports
深度学习:GCN(图卷积神经网络)理论学习总结
You can't specify target table 'table name' for update in from clause error resolution in MySQL
Hutool array tool
1542. Find the longest super substring hash + state compression
美团二面:为什么Redis会有哨兵?
Press Google and NVIDIA! Alibaba optical 800 chip won the world's first authoritative test again
Marvell公布旗下Arm服务器芯片路线图,下一代性能将比ThunderX2高两倍