Skip to main content

Lists schema example

This schema example shows how to define different types of list in a content type schema using the array keyword, including lists of strings, images and content items.

  • For each of properties we use the minItems and maxItems validation keywords to specify how many items can be added to the list. The type of content that can be added is defined by the items keyword.

  • If you want to ensure that the user enters at least one value for a list set minItems to your required number of items and include the property in the required fields. See the listOfStrings property below for an example of how to do this.

  • The listOfEnums property uses the unique keyword. This property allows the user to choose a list of values using pre-defined values. Each value can only be chosen once.

Pre-requisites
Link copied!

This is a self contained example that you can modify to meet your own requirements.

How to use
Link copied!

To use the listOfContentItems property, the media example must be registered (https://schema-examples.com/media). Alternatively you can modify listOfContentItems to include one of your own content types.

Lists example schema
Link copied!

Interactive

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

    Validation

    Strings

    Media and content choosers