如何设置自定义椭圆约束的优先级

时间:2015-05-26 01:53:25

标签: preconditions oval

我有一个自定义注释约束,但我希望只有在其他约束有效时才检查它。例如:

@NotNull
private String propertyA;
@Digits
private String propertyB;

如果propertyA为null,我不想要" @titits"在propertyB上进行检查。

我该如何解决这个问题?感谢。

1 个答案:

答案 0 :(得分:0)

您可以使用“when”属性,例如

@NotNull
private String propertyA;

@Digits(when="groovy:_this.propertyA!=null")
private String propertyB;

此示例要求Groovy运行时位于类路径中。您还可以使用其他脚本语言,请参阅http://oval.sourceforge.net/userguide.html#declaring-conditional-constraints