Sanity Library Reference Docs
    Preparing search index...

    Function defineArrayMember

    • Beta

      Define an array item member type within an array definition of-array.

      This function will narrow the schema type down to fields and options based on the provided type string.

      Using defineArrayMember is optional, but should provide improved autocompletion in your IDE, when building your schema. Field properties like validation and initialValue will also be more specific.

      See defineType for example usage.

      Type Parameters

      • const TType extends
            | "string"
            | "number"
            | "boolean"
            | "object"
            | "text"
            | "crossDatasetReference"
            | "reference"
            | "image"
            | "document"
            | "url"
            | "email"
            | "date"
            | "block"
            | "array"
            | "datetime"
            | "file"
            | "geopoint"
            | "globalDocumentReference"
            | "slug"
            | "sanity.video"
            | AutocompleteString
      • const TName extends string
      • TSelect extends Record<string, string>
      • TPrepareValue extends Record<keyof TSelect, any>
      • TAlias extends
            | "string"
            | "number"
            | "boolean"
            | "object"
            | "text"
            | "crossDatasetReference"
            | "reference"
            | "image"
            | "document"
            | "url"
            | "email"
            | "date"
            | "block"
            | "array"
            | "datetime"
            | "file"
            | "geopoint"
            | "globalDocumentReference"
            | "slug"
            | "sanity.video"
      • TStrict extends StrictDefinition

      Parameters

      Returns { name?: TName; type: TType } & DefineArrayMemberBase<TType, TAlias> & NarrowPreview<
          TType,
          TAlias,
          TSelect,
          TPrepareValue,
      > & MaybeAllowUnknownProps<TStrict> & WidenValidation & WidenInitialValue

      • Optionalname?: TName

        When provided, name is used as _type for the array item when stored.

        Necessary when an array contains multiple entries with the same type, each with different configuration (title and initialValue for instance).

      • type: TType
      • defineType
      • defineField
      • typed