Skip to main content

Validation schema example

This schema example demonstrates various validations available for text, numbers and arrays.

  • The simplestringwithmaxandmin property uses minLength and maxLength 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 and urlslug 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 10

  • The stringlistofenums demonstrates how to use an enum to constrain the values that can be added to a list. The uniqueItems 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.

  • The stringArray must contain a string with a length of 10 or more characters - validated using the contains keyword.

  • The numberArray property must contain an integer with a value of at least 10 - validated using the contains keyword.

Pre-requisites
Link copied!

None. This is a self contained schema.

How to use
Link copied!

You can use the validations demonstrated in this schema for your own properties.

Validations example
Link copied!

Interactive

This example is best viewed on a desktop browser where the schema editor is fully interactive.

    Validations