0

我正在尝试在 MVEL 表达式语言的 OVAL XML 配置文件中编写与以下 java Assert 语句等效的语句。但我无法这样做。任何帮助将不胜感激。

public class BusinessObject 
{
   // mailingAddress must either be the delivery address or the invoice address 
   @Assert(expr = "_value ==_this.deliveryAddress || _value ==  this.invoiceAddress", lang = "groovy")

   public String mailingAddress;
}

xml..

<class type="BusinessObject" applyFieldConstraintsToSetters="true" overwrite="false">
    <field name="mailingAddress">
        <assert lang="mvel" expr="_value ==_this.deliveryAddress || _value ==  this.invoiceAddress" message="mailingAddress must either be the delivery address or the invoice address ">
        </assert>
    </field>
4

1 回答 1

0

这应该有效:

<class type="BusinessObject" applyFieldConstraintsToSetters="true" overwrite="false">
   <field name="mailingAddress">
       <assert lang="mvel" message="mailingAddress must either be the delivery address or the invoice address">
           <expr>_value ==_this.deliveryAddress || _value ==  this.invoiceAddress</expr>
       </assert>
   </field>
</class>

另请参阅https://sourceforge.net/p/oval/code/HEAD/tree/trunk/src/test/resources/net/sf/oval/test/validator/XMLConfigurationTest.xml

于 2015-07-14T16:44:03.687 回答