Schema Libraries
Schema Libraries
This module works with any Standard Schema compatible library. Standard Schema is a shared interface that lets validation libraries work interchangeably.
This module works with any Standard Schema compatible library. Standard Schema is a shared interface that lets validation libraries work interchangeably.
Supported Libraries
| Library | Bundle Size | Style |
|---|---|---|
| Valibot | ~1KB | Functional, tree-shakeable |
| Zod | ~12KB | Method chaining |
| ArkType | ~25KB | Type-first, inference |
All provide the same validation capabilities. Choose based on your preference.
Standard Schema Benefits
- Swap libraries without changing module config
- Type inference works the same across libraries
- JSON Schema conversion handled automatically
Quick Comparison
import { number, object, optional, string } from 'valibot'
const schema = object({
apiKey: string(),
port: optional(number()),
})
import { z } from 'zod'
const schema = z.object({
apiKey: z.string(),
port: z.number().optional(),
})
import { type } from 'arktype'
const schema = type({
'apiKey': 'string',
'port?': 'number',
})