
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI understand your frustration! When you programmatically update a value in a custom input component via a button click, Sanity doesn't automatically re-run validation, which can leave the Publish button disabled even though your content is valid.
Unfortunately, there is no officially documented API to manually trigger validation in Sanity Studio's custom input components. According to the custom input components documentation, your component receives props like onChange, onFocus, and onBlur, but these are designed for updating values and managing focus state—not for explicitly triggering validation.
The validation system in Sanity Studio is primarily triggered by user interactions with form fields, and the internal validation mechanism isn't exposed as a callable method to custom components.
While these aren't officially documented solutions, developers in the community have found some approaches that sometimes work:
1. Try calling onBlur() after your update
Some developers report that calling onBlur() can sometimes prompt Studio to revalidate as a side effect:
const MyCustomInput = (props) => {
const { value, onChange, onBlur } = props;
const handleButtonClick = () => {
const newValue = /* your transformed value */;
onChange(set(newValue));
// May trigger revalidation as a side effect
if (onBlur) {
onBlur();
}
};
return (
<div>
{/* your input UI */}
<button onClick={handleButtonClick}>Transform</button>
</div>
);
};Important caveat: This isn't documented behavior and relies on a side effect. The onBlur prop is simply a focus management callback, not a validation trigger. It may not work consistently across Studio versions or could break in future updates.
2. Ensure you're using proper patch events
Make sure you're correctly using the PatchEvent system as described in the documentation:
import { set, unset } from 'sanity'
onChange(newValue ? set(newValue) : unset())3. Focus/blur a hidden input element
Some developers add an invisible native input that you can programmatically focus and blur:
const inputRef = useRef(null);
const handleButtonClick = () => {
const newValue = /* your transformed value */;
onChange(set(newValue));
// Attempt to trigger validation through focus cycle
inputRef.current?.focus();
inputRef.current?.blur();
};
return (
<div>
<input
ref={inputRef}
style={{ opacity: 0, position: 'absolute', pointerEvents: 'none' }}
tabIndex={-1}
/>
{/* your actual UI */}
</div>
);Again, this is a workaround that exploits how Studio's validation might be triggered internally—not an official API.
If these workarounds feel fragile (because they are), consider whether you can adjust your component's design:
Since this is a common pain point without a documented solution, I'd recommend:
revalidate() API in custom input componentsThe lack of a documented validation trigger API is a real limitation when building custom inputs with programmatic updates, and the Sanity team would benefit from hearing about your use case.
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