jazsouf
Web developer
jazsouf is located at Paris
This validation can be used if you have an object with two fields and you require one or the other to be filled
export default {
name: "mediaObject",
title: "My Media Object",
type: "object",
fields: [
{
name: "videoUrl",
title: "Video url",
type: "string",
validation: (Rule) =>
Rule.custom((videoUrl, {parent} : any) =>
typeof parent.image === "undefined" && typeof videoUrl === "undefined"
? "Either Video url or Image must have a value"
: true
),
},
{
name: "image",
title: "Image",
type: "image",
validation: (Rule) =>
Rule.custom((image, {parent} : any) =>
typeof parent.videoUrl === "undefined" && typeof image === "undefined"
? "Either Video url or Image must have a value"
: true
),
},
],
};
There is a snippet about how to do this type of custom validation at the document level by Roboto Studio.
This is the code adapted if you're working on an object instead of a document.
Web developer
Alternative solution to Webhook revalidation
Go to Next.js on-demand Tag Revalidation with Custom Document Actions