Search code examples
orbeon

Orbeon: Check text for valid JSON string


We paste a JSON string into one of our form controls which is then used by another application to generate data.

We need a way of validating this json string before the form is saved/submitted.

How can we achieve this?

Many thanks in advance.

PeteA


Solution

  • In the Control Settings dialog for your text area, navigate to the Validations and Alerts tab and use the following formula to validate the value of the field (as shown in the screenshot below).

    exists(xxf:json-to-xml(.))
    

    Control Settings dialog