
Valibot Has a Free Schema Validation Library — Here's How to Use It
Zod is great but ships 57KB to your users' browsers. Valibot does the same thing at under 1KB — up to 98% smaller bundle size with the same developer experience. What Is Valibot? Valibot is a TypeScript-first schema validation library. It uses a modular, tree-shakeable architecture that means you only ship the validators you actually use. Bundle Size Comparison Library Bundle Size Tree-Shakeable Valibot ~0.5-1KB Yes (modular) Zod ~57KB No (monolithic) Yup ~40KB Partial Joi ~150KB No Quick Start npm install valibot import * as v from ' valibot ' ; const UserSchema = v . object ({ name : v . pipe ( v . string (), v . minLength ( 2 ), v . maxLength ( 100 )), email : v . pipe ( v . string (), v . email ()), age : v . pipe ( v . number (), v . minValue ( 0 ), v . maxValue ( 150 )), role : v . picklist ([ ' admin ' , ' user ' , ' moderator ' ]), }); type User = v . InferOutput < typeof UserSchema > ; // { name: string; email: string; age: number; role: 'admin' | 'user' | 'moderator' } // Val
Continue reading on Dev.to Webdev
Opens in a new tab


