Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.

feat: add document-level validator#157

Draft
nkgentile wants to merge 3 commits intosanity-io:mainfrom
nkgentile:feature/add-document-validation
Draft

feat: add document-level validator#157
nkgentile wants to merge 3 commits intosanity-io:mainfrom
nkgentile:feature/add-document-validation

Conversation

@nkgentile
Copy link
Contributor

@nkgentile nkgentile commented Sep 26, 2023

Export a custom, document-level validation function that a user can register on their schema types:

import {defineType} from 'sanity'
import {referenceLanguageValidator} from '@sanity/document-internationalization'

export const article = defineType({
  title: 'Article',
  name: 'article',
  type: 'document',
  // ..rest of the schema definition
  validation: (rule) =>
    // You can decide whether this will trigger a warning
    // or an error in the Studio
    rule.custom(referenceLanguageValidator).warning(),
})
Screenshot 2023-09-26 at 4 11 54 PM

@nkgentile nkgentile changed the title feature/add document validation feat: add document-level validator Sep 26, 2023
@socket-security
Copy link

New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
@types/traverse 0.6.32 None +0 8.82 kB types
@sanity/icons 2.2.2...2.4.1 None +0/-0 1.15 MB sanity-io

🚮 Removed packages: @sanity/ui@1.3.1, sanity@3.8.3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant