AnsweredAssumed Answered

Conditional aspects?

Question asked by probert@oaciq.com on Mar 26, 2013
Latest reply on Mar 26, 2013 by michaelböckling
Hi,

I have a document model like this;

<type name="oaciqdt:docLfermAssist">
  <title>lferm-assist</title>
  <parent>oaciqdt:docAssistanceSyndic</parent>
  <mandatory-aspects>
    <aspect>oaciqdt:aspectIntervenant</aspect>
    <aspect>oaciqdt:aspectIdentifiantIntervenant</aspect>
    <aspect>oaciqdt:aspectNumsPermis</aspect>
  </mandatory-aspects>
</type>   

The issue we have is that oaciqdt:aspectNumsPermis should be conditional, e.g. it should be mandatory if a value for the property who is part of that aspect is not null. The aspect is like this:

<aspect name="oaciqdt:aspectNumsPermis">
  <title>License numbers</title>
  <properties>
    <property name="oaciqdt:numsPermis">
      <type>d:text</type>
      <multiple>true</multiple>
      <constraints>
        <constraint name="oaciqdt:numsPermisREGEX" type="REGEX">
          <parameter name="expression"><value>[A-Za-z]{1}[0-9]{4}</value></parameter>
          <parameter name="requiresMatch"><value>true</value></parameter>
        </constraint>
      </constraints>
     </property>
  </properties>
</aspect>

So in short, if oaciqdt:numsPermis is empty, I don't want the validation to occur, but if the value is not empty, the regex should be run.

Looking at the documentation, I don't see how you can define a property to validate only if a value is present, and I don't see how we can make the aspect to be conditional if the value is empty.

Any tricks?

Outcomes