Set Up a Custom Validation

XML Forms Guide

Version
R2024.1.1
Set Up a Custom Validation

Using a custom rule, you can validate the form data against whatever condition you choose.

The following validation checks to make sure the specified end date is later than the start date:

Copy
<ValidationRule Event="OnSubmit" Type="Custom">
    <Parameter Name="Condition">List_PersonAddress.EffectiveStart
        LessThan coalesce(List_PersonAddress.EffectiveEnd,maxdate())
    </Parameter>
    <Parameter Name="ValidationFailureMessage">
        The end date cannot be earlier
        than the start date.</Parameter>
</ValidationRule>

A custom validation rule must include:

  • A <ValidationRule> tag where Type=”Custom”
  • A Condition parameter
  • A ValidationFailureMessage parameter

The Condition parameter provides the logic to be tested against the form data. If the form data satisfied the condition, it’s considered valid. Otherwise, an error message is displayed. See Assemble Conditions.

The ValidationFailureMessage parameter provides the error message to be displayed if the form data does not satisfy the Condition. You can provide a literal string or a localizable variable.