tldraw/tldraw
@tldraw/validate
Active contributors: Steve Ruiz, David Sheldrick, Mitja Bezenšek
Purpose
@tldraw/validate is a tiny, dependency-free runtime validator. It is used by @tldraw/tlschema to validate every record before it enters the store. Think Zod-shaped, but trimmed to the shapes the schema needs.
Directory layout
packages/validate/src/lib/
├── validation.ts # the core combinators
└── ...Key abstractions
| Type | Purpose |
|---|---|
T (the validator namespace) |
T.string, T.number, T.boolean, T.literal, T.object, T.union, T.array, T.nullable, T.optional, etc. |
Validator<T> |
Has a validate(value): T method that throws on mismatch. |
How it works
Validators are composed: T.object({ x: T.number, y: T.number }) builds a validator for {x:number, y:number}. Records define their shape with these combinators in their record file (e.g., TLShape.ts).
Integration points
- Imports. None.
- Importers.
@tldraw/tlschema, indirectly via re-exports.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.