Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

How to Make a Field Mandatory or Required in the Studio

1 replies
Last updated: May 10, 2021
In sanity studio how do you make a field required so that they cant leave it blank or make a default entry, eg the slug field is automatically generated using the title
May 10, 2021, 8:54 AM
user V
! You can do this by adding a required validation rule to the field, here is an example:
      title: 'slug',
      name: 'slugName',
      type: 'slug',
      validation: (Rule) => Rule.required(),
Here is the documentation on validation for further context:
https://www.sanity.io/docs/validation Also, here is documentation for the slug field that provides the validation and options available specifically for slugs:
https://www.sanity.io/docs/slug-type I hope this helps!
May 10, 2021, 2:46 PM

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?