@sanity/cli
Version:
Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets
19 lines (14 loc) • 379 B
text/typescript
import {SlugRule} from 'sanity'
const MAX_LENGTH = 96
export const validateSlug = (Rule: SlugRule) => {
return Rule.required().custom((value) => {
const currentSlug = value && value.current
if (!currentSlug) {
return true
}
if (currentSlug.length >= MAX_LENGTH) {
return `Must be less than ${MAX_LENGTH} characters`
}
return true
})
}