Full Boundary Validation
Fluent schemas with constraints, refinements, preparation, casting, composition, and TypeScript inference.
A JavaScript runtime schema validator written in TypeScript, with type safety and inference.

I am small and fast. I do one thing well: I validate stuff.
At the app's edge, a shape comes in, Dot checks it, and you move on to business logic.
import {dot} from '@sajajs/dot'
const UserSchema = dot.object({
id: dot.string()
.min(4)
.as(s => dot.int().gte(1000).validate(Number(s))), // cheap, no hoisting required
name: dot.string()
.min(1)
.prepare(s => s.trim())
.refine(s => s.toLowerCase() !== 'root', 'reserved name'),
role: dot.enum(['admin', 'predator']).optional(),
tags: dot.array(dot.string().min(2)).min(1).nullable()
}).strict()
type User = dot.infer<typeof UserSchema>
// {id: number, name: string, role?: 'admin' | 'predator', tags: string[] | null}
const user: User = UserSchema.validate({
id: '12354',
name: ' Dot ',
role: 'predator',
tags: ['small', 'fast']
})
// {id: 12354, name: 'Dot', role: 'predator', tags: ['small', 'fast']}