Validation keywords are used to specify constraints on the content of a particular type and to ensure that it is valid. For example, strings will generally have a minimum and maximum length, as will numbers, and arrays will also have a minimum and maximum number of items. These limits will be specified in the content type and enforced by the user interface in the Content Editing window.
- Validation keywords provide a way of constraining content to ensure that it is valid
- We support most of the keywords defined in the JSON Schema standard with a few exceptions
- enum is a particularly useful keyword for use in content types so we have included some examples of its use. Examples of other validations can be found on the property types and strings pages.
Property types also provide validation, including the format of string items. Specifying a uri format string constrains the format to a standard uri, while the email format ensures that the string entered is a valid format email address.
We support a subset of the validation keywords defined in the JSON Schema Validation specification and these are listed on this page, together with the unsupported keywords.
Supported validation keywords
Expand the list below to see the supported validation keywords, together with the types they apply to.
Validation keywords for number and integer
Validation keywords for strings
Validation keywords for arrays
Validation keywords for any instance type
Validation keywords for combining schemas
Each of these keywords must be set to an array, where each item is a schema.
allOf: Must be valid against all of the subschemas
anyOf: Must be valid against any of the subschemas
Unsupported validation keywords
The following validation keywords are currently not supported. The platform will not reject these keywords where they are included in content types, but developers should not expect these keywords to be interpreted by the user interface when users are adding content.
Expand the section below to see the list of unsupported validation keywords.
enum is a very useful keyword, both for constraining the contents of an array and for providing a list of items for the user to choose from. In the partial snippet shown below, the slides property is an array of content types, constrained by the enum. We could just add another content type to the enum to allow it to be added.
The example below shows how to use an enum to define a list of items from which the user can choose. In this example it's just to choose left or right alignment of some text:
This is how the enum will be displayed by the user interface.
The user clicks in the field in the Content Editing window and chooses the value they want. Note that none is an option.