使用注释验证字段 [英] validate fields using annotations

查看:78
本文介绍了使用注释验证字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

是否可以使用注释验证数据类型字段?



例如:

如果我有班级:



Hello,
is it possible to validate datatypes fields using annotations ?

for example:
if i have the class:

public class Worker{
   
 @NameAnno
  private String name;
 @EmailAnno
  private String email;

  public Worker()
  {
     name = "AnyName";
     email = "notLegal&email.blabla"
  }
}





所以当构造函数运行时,会发生异常。

我的主要目标是每个分配在字符串中,自动验证只会发生注释并且不会调用其他检查方法。



谢谢!



so when the constructor will run, exception will happened.
my main goal is in each assign into the strings , auto validate will happened only with annotations and with out calling to other checking method.

thanks !

推荐答案

尝试阅读 JaValid 的文档[ ^ ]。可能有用。
Try reading the documentation for JaValid[^]. Might be of use.


这篇关于使用注释验证字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆