Saskia Bobinska
Support Engineer @Sanity
Validation of url input to allow certain URI schemes (mailto, tel and more included)
{
name: 'url',
title: 'Url',
type: 'url',
description: `Can be a path starting with a '/' or a full Url starting with 'http://' or 'https://'`,
validation: (Rule) =>
Rule.uri({
allowRelative: true,
scheme: ['http', 'https', 'mailto', 'tel'],
}),
},
Sometimes we want to make sure, users can add links for tel:
and mailto:
too.
To make sure these URI
schemes are allowed and won't result in warnings and errors, you can add this validation to your url
schema field and make sure, the urls are right, no matter what they open!
Support Engineer @Sanity
When creating custom document actions, it can be necessary to check, wether all validation rules are full-filled.
Go to Use the validation status of a document in your custom document actionsOnly return a value when a condition is fulfilled
Go to Conditional values in GROQ queriesIf you want to make it possible to use parameterised initialValue templates in reference fields, this is how!
Go to Create a new reference document with parameterised initial ValuesSometimes you need to change only one key-value-pair in your data, this is how you can do it in 2 lines
Go to Create a copy of an object and change a key-value pair