Conditionals
Conditionals (if/ then/ else) allow you to set the state and value of one or more properties in a schema, based on the state of another property. For example, you can use conditionals to enable or disable a property based on a user selection, or hide or show one or a group of properties.
On this page we've provided examples of some of the common uses for conditionals. See conditionals- schema examples for more.
Info
We don't currently support all of the features specified in the JSON schema conditionals reference. In particular, wrapping multiple if/then conditions inside allOf is not supported. However using content palettes with objects does provide an alternative way to structure your schema to support choosing one from a number of options.
Hiding and showing propertiesLink copied!
In this example the date property is shown or hidden based on the state of the hasDate boolean.
Hiding and showing properties based on validationLink copied!
In the following example additionalNotes is shown if the email property is a valid email address, according to the regular expression defined in the pattern.
Conditional validationLink copied!
In the example shown below, the country property is used to determine the validation used for the addressCode property. Different validation is used for a UK or US address.