scribbleValidator
See source codeA validator for TLScribble objects.
This validator ensures that scribble objects have all required properties with valid types and values. It validates the points array, size constraints, color types, and state values according to the scribble system requirements.
scribbleValidator: T.ObjectValidator<TLScribble>
Example
import { scribbleValidator } from '@tldraw/tlschema'
// Validate a scribble object
try {
const validScribble = scribbleValidator.validate({
id: 'scribble-1',
points: [
{ x: 0, y: 0, z: 1 },
{ x: 10, y: 10, z: 1 },
],
size: 3,
color: 'black',
opacity: 0.8,
state: 'active',
delay: 0,
shrink: 0.05,
taper: true,
})
console.log('Valid scribble:', validScribble)
} catch (error) {
console.error('Invalid scribble:', error.message)
}
Prev
rootShapeMigrationsNext
shapeIdValidator