Lists
This schema snippet 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
andmaxItems
validation keywords to specify how many items can be added to the list. The type of content that can be added is defined by theitems
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 therequired
fields. See thelistOfStrings
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-requisitesLink copied!
This is a self contained example that you can modify to meet your own requirements.
How to useLink 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 schemaLink copied!
Content form previewLink copied!
An example of creating a content item using a content type registered from the lists example schema is shown in the image below.