sanity
Version:
Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches
21 lines (19 loc) • 479 B
text/typescript
import {isArraySchemaType, isObjectSchemaType, type SchemaType} from '@sanity/types'
export function createProtoValue(type: SchemaType): any {
if (isObjectSchemaType(type)) {
return type.name === 'object' ? {} : {_type: type.name}
}
if (isArraySchemaType(type)) {
return []
}
if (type.jsonType === 'string') {
return ''
}
if (type.jsonType === 'number') {
return 0
}
if (type.jsonType === 'boolean') {
return false
}
return undefined
}