| Package | Version | Description |
|---|---|---|
| @sylphx/vex | Schema validation library |
npm install @sylphx/veximport { pipe, str, num, int, email, positive, object, safeParse } from '@sylphx/vex'
const validateUser = object({
name: pipe(str, nonempty),
email: pipe(str, email),
age: pipe(num, int, positive),
})
// Throws on error
const user = validateUser(data)
// Returns result
const result = safeParse(validateUser)(data)Pure functional design - validators are constants, not factory functions:
// Vex - zero allocation
str // constant
pipe(str, email) // compose constants
// Others - allocates every call
z.string().email() // Zod
v.string() // Valibot| Vex | Zod | Valibot | |
|---|---|---|---|
| Speed | ⚡ 12x | 1x | ~2x |
| Schema creation | Zero overhead | Slow | Medium |
| Tree-shakeable | ✅ | ❌ | ✅ |
| Operation | Vex | Zod | Valibot | vs Zod | vs Valibot |
|---|---|---|---|---|---|
| string | 367M | 50M | 50M | 7.4x | 7.3x |
| 128M | 12M | 17M | 11x | 7.5x | |
| url | 110M | 4M | 5M | 28x | 23x |
| object (3 fields) | 18M | 5M | 7M | 3.9x | 2.7x |
| array[50] | 8.5M | 780K | 1.4M | 11x | 6x |
| safeParse (invalid) | 44M | 376K | 2.6M | 118x | 17x |
Average: 12x faster than Zod, 6x faster than Valibot
# Install
bun install
# Test
bun test
# Benchmark
bun run bench
# Build
bun run buildMIT
Built with ❤️ by Sylphx