Validation of url input to allow certain URI schemes
Validation of url input to allow certain URI schemes (mailto, tel and more included)
url schema with uri validation
{
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!
Contributor

Saskia Bobinska
Senior Support Engineer @Sanity
Germany