Field Validation in Schemas - Setting Validation: False On A Document Or A String Field
I can see there's some confusion here! The phrase "Sometimes you can set validation: false on a document or a field to disable it" doesn't mean it will disable editing of the field. That documentation is talking about disabling validation rules, not disabling the field itself.
Setting validation: false simply means the field won't have any validation rules applied to it - the field will still be fully editable, it just won't require any specific format, won't be required, etc.
If you want to make a field non-editable, you need to use the readOnly property instead:
{
name: 'myField',
type: 'string',
readOnly: true
}You can also make fields conditionally read-only based on document state:
{
name: 'myField',
type: 'string',
readOnly: ({document}) => document?.isPublished === true
}Similarly, if you want to hide a field entirely (rather than just making it read-only), use the hidden property:
{
name: 'myField',
type: 'string',
hidden: true
}Or conditionally:
{
name: 'myField',
type: 'string',
hidden: ({parent, document}) => !document?.showAdvancedFields
}The readOnly and hidden properties work on any field type including strings, and they can be applied at both the field level. Both properties support conditional logic using callback functions that receive parent, document, value, and currentUser as parameters.
So to summarize:
validation: false= no validation rules (field is still editable)readOnly: true= field is visible but not editablehidden: true= field is not visible in the Studio
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.