Use the Counting Validation Rule

XML Forms Guide

Version
R2024.1.1
Use the Counting Validation Rule

Using a counting validation rule, you can test whether the number of entries for a particular data element matches a particular condition. The following validation rule checks to make sure that at least one US address was entered for the employee:

Copy
<ValidationRule Event="OnSubmit" Type="Counting">
    <Parameter Name="Object">List_PersonAddress</Parameter>
    <Parameter Name="Condition">List_PersonAddress.CountryCode Equals "USA"
    </Parameter>
    <Parameter Name="MinCount">1</Parameter>
    <Parameter Name="ValidationFailureMessage">
        You must enter at least one US address for this employee.
    </Parameter>
</ValidationRule>

A counting validation rule must include:

  • A <ValidationRule> tag where Type=”Counting”
  • An Object parameter
  • A Condition parameter
  • A count parameter (either Count, MinCount, or MaxCount)
  • A ValidationFailureMessage parameter

The Object parameter identifies the data element in the WF_Entity object model to be counted.

The Condition parameter filters the objects to be counted using the specified condition. See Assemble Conditions.

The count parameter specifies the valid number of entries for the identified object, and whether the count must match this number exactly (Count), meet or exceed the number (MinCount) or not exceed this number (MaxCount).

The ValidationFailureMessage parameter provides the error message to be displayed if the number of entries counted violates the rule. You can provide a literal string or a localizable variable.