
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI understand you're seeing an issue where a required reference field still validates as valid after you remove the relation. Let me help clarify what's happening here.
When you "remove" a reference in Sanity Studio, you might be seeing one of these scenarios:
null or undefined - In this case, the required() validation should catch it and show an errorAccording to the reference type documentation, a valid reference must have both:
_type: 'reference'_ref: '<document-id>'The built-in required() validation should prevent publishing when a required reference field is empty or missing.
First, let's verify what's actually in your document when you "remove" the reference:
Check the document data: Open your browser's developer console and inspect what value the field actually contains when you think it's removed. You can do this by looking at the document state in Sanity Studio.
Verify your schema: Make sure your reference field is properly configured:
{
name: 'myReference',
type: 'reference',
to: [{type: 'targetType'}],
validation: (rule) => rule.required()
}If you're genuinely seeing validation pass with a missing required reference, you can add explicit custom validation as a workaround:
{
name: 'myReference',
type: 'reference',
to: [{type: 'targetType'}],
validation: (rule) => rule.required().custom((value) => {
// Explicitly check for a valid reference
if (!value?._ref) {
return 'This reference is required'
}
return true
})
}This custom validation explicitly checks that the _ref property exists, which contains the actual document ID.
Keep in mind that validation in Sanity Studio is client-side only. This means:
If you're consistently able to reproduce this issue with specific steps, I'd recommend reporting it on the Sanity GitHub repository with details about your schema configuration and the exact steps to reproduce, as this would help the team investigate whether there's a genuine bug in the validation system.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store