Search code examples
validationxpathorbeonxforms

Orbeon Form Builder validation constraint on repeating element


I am using Orbeon Form Builder and have a form with a repeat section, containing a field named address as well as some other fields.

There can be a minimum of 4 repeats and a maximum of 6.

Is there a way to add a constraint on the repeating address field to make it mandatory unless it is the last item?


Solution

  • Say your repeat grid name is address (this is the name of the repeat grid, not the field). Then on the field you can use the following constraint:

    empty(../following-sibling::address) or . != ''
    

    Essentially, you're saying that this field is always valid if there are no following address iterations (which means we're on the last line), and other its value must be non-empty.