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.
{label: "Title",name: "title",type: "string",ui: {validate: (value, data)=>{const lengthOfTitle = value?.length || 0const lengthOfDescription = data?.description?.length || 0if(lengthOfTitle >= lengthOfDescription){return 'The description must be longer than the title'}}}}
The following schema types support the use of validate
:
Product
Resources
© TinaCMS 2019–2024