Introduction
Core Concepts
Querying Content
Editing
Customizing Tina
Going To Production
Drafts
Guides
Further Reference

Tina allows client-side validation using a validation function. This function returns a string error message if the value is invalid or null if the field is valid.

To include other field values of the form in the validation, a data argument can be used.

Example

Validate the length of a `string` field

{
label: "Title",
name: "title",
type: "string",
ui: {
validate: (value, data)=>{
const lengthOfTitle = value?.length || 0
const lengthOfDescription = data?.description?.length || 0
if(lengthOfTitle >= lengthOfDescription){
return 'The description must be longer than the title'
}
}
}
}

The following schema types support the use of validate: