JSR303 验证:两个(或多个)验证约束:第一个返回错误后,不评估第二个?
给定以下两个约束
@NotNull
@Pattern (pattern="foobar")
private String myFooBarMember;
,如果第一个约束(=返回错误)(@NotNull)是否有可能不评估第二个约束(@Pattern)?或者 JSR303 总是评估所有约束?如果有可能在第一场比赛后不评估第二场比赛,请说明如何做到这一点。
非常感谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我不是 JSR 303 专家,但我从 1.0 FR:
和:
因此,从后者来看,我想说默认情况下所有验证器都会被执行。
从前者来看,我想说这(约束组合)将是实现你想要的目标的一种方法。尽管它可能(而且很可能)依赖于 Bean Validation 实现者,所以您需要阅读一些专有文档。
Well, I'm not a JSR 303 specialist, but I've found the following excerpts from the 1.0 FR:
and:
So from the latter, I'd say that by default all validators will be executed.
From the former, I'd say that this (constraint composition) would be one way to achieve what you want. Although it might (and probably is) dependent on the Bean Validation implementor, so you'd need to read some proprietary docs.