Join us live Sept. 27 – How Sanity and Vercel powered Morning Brew's transformation –>

Does anybody know how to validate the document before allowing publication?

3 replies
Last updated: Sep 24, 2020

Hi!I am using a document workflow based on
https://github.com/sanity-io/demo-custom-workflow .In this the publish action defined in publish.js, publishes via the following line:

ops.publish.execute()
But it seems that this publishes without validating the document at hand.

Does anybody know how to validate the document before allowing publication?

Sep 24, 2020, 8:08 AM

there's also a validation hook iirc

Sep 24, 2020, 9:35 AM

Perfect, just what I was looking for - thanks!

Sep 24, 2020, 9:36 AM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.