Unlock seamless workflows and faster delivery with our latest releases – get the details

How to Make the Alt Text Required From the Asset Library

3 replies
Last updated: Aug 31, 2021
Hello, I'm building my first project with Sanity and I have a question about the asset document fields. Is it possible to make the alt text required from the asset library? I would like to avoid duplicating the field in my image schema.
Aug 31, 2021, 9:24 AM
Thank you for the answer, i tried that but I can't change the sanity image asset schema to make the alt field required right ?
Aug 31, 2021, 10:16 AM
I guess you can, but its data will be stored to the image field’s document , and not the asset document if that makes sense.
{
  name: 'image',
  type: 'image',
  fields: [
    { 
      name: 'alt',
      type: 'string',
      validation: Rule => Rule.required()
    }
  ]
}

Aug 31, 2021, 10:29 AM
Thanks! I will do that
Aug 31, 2021, 10:48 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?