<wd:field id="persontype"> <wd:datatype base="integer"/> </wd:field>
<!-- NaturalPerson -->
<wd:field id="lastname">
<wd:label><i18n:text key="lastname"/></wd:label>
<wd:datatype base="string">
<wd:validation>
<wd:assert test="If(persontype = 0, Not(IsNull(lastname)), true)"/>
</wd:validation>
</wd:datatype>
</wd:field>
<wd:field id="firstname">
<wd:label><i18n:text key="firstname"/></wd:label>
<wd:datatype base="string">
<wd:validation>
<wd:assert test="If(persontype = 0, Not(IsNull(firstname)), true)"/>
</wd:validation>
</wd:datatype>
</wd:field><!-- LegalPerson -->
<wd:field id="name">
<wd:label><i18n:text key="name"/></wd:label>
<wd:datatype base="string">
<wd:validation>
<wd:assert test="If(persontype = 1, Not(IsNull(name)), true)"/>
</wd:validation>
</wd:datatype>
</wd:field>
<wd:field id="commercialRegisterNumber">
<wd:label><i18n:text key="commercialRegisterNumber"/></wd:label>
<wd:datatype base="string">
<wd:validation>
<wd:assert test="If(persontype = 1, Not(IsNull(commercialRegisterNumber)), true)"/>
</wd:validation>
</wd:datatype>
</wd:field>
The validation should be clear IMO:
If persontype 0 is selected the lastname and the firstname must not be null, otherwise return true.
If persontype 1 is selected the name and the commercialRegisterNumber must not be null, otherwise return true.
This works if I sent a form with persontype = 1 and both the fields name and commercialRegisterNumber not null. But if does not work if I switch to persontype 0 with the fields lastname and firstname null. There the validation for the fields name and commercialRegisterNumber fail though they are not null! Seems to be somewhat strang IMO.
Does anybody see an obvious mistake or know why?
Joerg
[1] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=107352171910636&w=4 [2] http://xreporter.cocoondev.org/en/expressions.html
