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.
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 ?
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()
    }
  ]
}

Thanks! I will do that

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?