Validations
This schema snippet demonstrates the various validations available for text, numbers and arrays.
The
simplestringwithmaxandmin
property usesminLength
andmaxLength
to constrain the length of the string. This property is also included in the properties listed as required, so a valid value must be entered in the property before it can be saved.The
dateWithPattern
andurlslug
properties demonstrate how to constrain the value entered using a regular expression defined by the pattern keyword. You can find out more about regular expressions in JSON Schema in the JSON Schema documentation.The
numbervalidationexample
shows how to use the multipleOf keyword, for a number that must be a multiple of 10The
stringlistofenums
demonstrates how to use an enum to constrain the values that can be added to a list. TheuniqueItems
keyword is also used to ensure that each value can only be chosen once. This property is also required, so a valid value must be entered before the the content item can be saved. Users have a choice of selecting "none" if the array uses an enum.
Pre-requisitesLink copied!
None. This is a self contained schema.
How to useLink copied!
You can use the validations demonstrated in this schema for your own properties.
Validations exampleLink copied!
Content form previewLink copied!
An example of creating a content item using a content type registered from the validations example schema is shown in the image below.