Saskia Bobinska
Support Engineer @Sanity
Saskia is located at Berlin Germany
An Email field, that uses Regex-Validation.
{
name: 'email',
title: 'Email',
type: 'string',
validation: Rule => Rule.custom(email => {
if (typeof email === 'undefined') {
return true // Allow undefined values
}
return email.toLowerCase()
.match(
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
)
? true
: 'This is not an email'
})
}
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