如何在解析过程中执行电子邮件类型验证(使用OpenCSV、Spring Boot)?

huangapple 未分类评论53阅读模式
英文:

How to perform Email type verification during parsing(OpenCSV, spring boot)?

问题

我正在使用opencsv在Spring Boot中从csv文件中读取数据。
和往常一样,我使用了@CsvBindByName注解,将csv的每一列绑定到所需的实体成员上。
但是假设我有一个字符串字段,它必须具有电子邮件的结构,是否存在一个注解来正确解析并检查它是否符合正确的电子邮件格式?

示例:

@Email
@CsvBindByName(required = true)
private String email;

非常感谢!

英文:

I am using opencsv to read from a csv file in Spring boot.
Like usual, I have used @csvbindbyname annotation to bind every column(of csv) to the required entity member.
But say if I have a string field, which must have the structure of an Email, is there an annotation present to parse correctly and check if it follows a correct email pattern??

Example

@Email
@CsvBindByName(required = true)
private String email;

Thank you so much!

huangapple
  • 本文由 发表于 2020年6月29日 05:17:23
  • 转载请务必保留本文链接:https://java.coder-hub.com/62628320.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定