Conditional statements

Conditional statements are used with required, inForm and inDocument properties to make them conditional on values in the document.

They may only refer to 1) values which are not modified by this form, 2) values which are modified by an element which is defined by before this element, or 3) external data values set with the externalData() function on the FormInstance.

Conditional statements are defined using JSON compatible data structures, as functions cannot be serialised into JSON.

The path property is used to refer to a value in the form. See Value path handling for details.

The externalData property specifies the key which refers to the external data value set with the externalData() function on the FormInstance. This is ignored if path property is specified and it is a simple dictionary key so it doesn’t behave like path property.

The operation property defines what operation is performed.

Equality and inequality

Use the "===" operation to test the value at path or externalData for equality with a constant value, and the "!==" operation to test for inequality. Example:

    {
        "path": "path.to.value",
        "operation": "===",
        "value": 17
    }

"=" and "==" are aliases of "===".

"!=" is alias of "!==".

Relational

Use the "<", "<=", ">" or ">=" operation to test the value at path or externalData for being smaller than, smaller than or equal to, greater than, or greater than or equal to respectively with a constant value. Example:

    {
        "path": "path.to.value",
        "operation": "<",
        "value": 5
    }

Defined and undefined values

Use the "defined" and "not-defined" operations to test whether value at path is present in the document or value at externalData is present in the external data.

    {
        "path": "some.value",
        "operation": "not-defined"
    }

Value is contained in an array

Use the "contains" and "not-contains" operations to test whether the array at path or externalData contains (or doesn’t contain) a given value.

    {
        "path": "some.array",
        "operation": "contains",
        "value": "v1"
    }

Array has a minimum count

Use the "minimum-count" operation to test whether the array at path or externalData has at least the given number of elements.

    {
        "path": "some.array",
        "operation": "minimum-count",
        "value": 5
    }

Boolean operators

Use the "AND" and "OR" operations to combine the tests in the statements array. Boolean operations may be nested.

    {
        "operation": "AND",
        "statements": [
            {"path":"value1", "operation":"===", value:24},
            {"path":"value2", "operation":"defined"}
        ]
    }