Structured Content 2022: Join our conference to explore fresh perspectives on content and digital experiences →

Array type has a invalid value for property "of"

All array types must define what kind of items they may contain. The "of" property must be an array of objects that describes the type of a valid item. Each entry in of, must have a type-property which must be the name of a valid schema type.

{
  type: 'array',
  name: 'items',
of: [ // The "of"-property must be set, and it must be an array
{
type: 'author', // type is required
title: 'Author' }, { type: 'book', title: 'Book' } ] }

Types must be unique, or named

In order to know which type description an array item belongs to, you can not add multiple entries to of with the same name, unless giving them a name to tell them apart. This is therefore not allowed:

{
  type: 'array',
  name: 'items',
  of: [
    {
      type: 'author',
      title: 'Author'
    },
    {
      type: 'author', // 💥 ERROR will not be able to tell array items apart
      title: 'Another author'
    }
  ]
}

Instead, you can give items of the same type another name. This will work:

{
  type: 'array',
  name: 'items',
  of: [
    {
      type: 'author',
      title: 'Author'
    },
    {
      type: 'author',
name: 'anotherAuthor', // all good
title: 'Another author' } ] }

Items in this array will have their _type set to either author or anotherAuthor, depending on which of the types were selected when the item was added e.g.:

[
  {"_type": "author", "name": "Camilla Collett"},
  {"_type": "anotherAuthor", "name": "Henrik Ibsen"}
]

Was this article helpful?