Operators
There are four operators: (i) allOf, (ii) anyOf, (iii) oneOf, and (iv) not. Operators are used to specify conditions of validity as explained below. You can add an operator to any definition. To access the operator sub-menu, right-click the definition to which you wish to add an operator, and then select Add Child | Operator (see screenshot below).
These operators specify conditions for successful validation, as follows:
Operator | Icon | Description |
All Of | Contains one or more sub-schemas (definitions), added as children of the operator. An instance is valid if it is valid against all these sub-schemas. | |
Any Of | Contains one or more sub-schemas (definitions), added as children of the operator. An instance is valid if it is valid against at least one of these sub-schemas. | |
One Of | Contains one or more sub-schemas (definitions), added as children of the operator. An instance is valid if it is valid against exactly one of these sub-schemas. | |
Not | Contains exactly one sub-schema (definition), added as a child of the operator. An instance is valid if it is invalid against the given definition. |
The screenshot below shows a One Of operator that contains three child sub-schemas (definitions). For the instance to be valid, it must have one JSON data structure (at this point in the document structure) that matches one of the three sub-schema definitions.
Operators can be useful for specifying inheritance and restriction. The screenshot below, for example, shows how to use the All Of operator to define an array containing non-empty unique strings.