Zod Schema Validation
www.npmjs.com
1
Leaving SiteNav
External Link Disclaimer
You are about to visit www.npmjs.com. This website is not operated by us. We are not responsible for its content or privacy practices.
About this website
Zod is a TypeScript-first schema validation library created by Colin McDonnell in 2020, providing a declarative API for defining schemas that serve as both runtime validators and TypeScript type definitions, enabling single-source-of-truth validation with full type safety, supporting strings, numbers, booleans, dates, arrays, objects, unions, intersections, enums, literals, optional and nullable values, records, maps, sets, promises, functions, and custom types, adopted by over five million weekly npm users and by frameworks including tRPC, Remix, Next.js, and shadcn/ui for input validation and type-safe data handling. The TypeScript-first design means that every Zod schema definition automatically generates a corresponding TypeScript type through the infer operator, eliminating the need to manually define both a validation schema and a TypeScript interface, ensuring that the runtime validation and compile-time types never drift out of sync, with type narrowing automatically refining types after successful validation. The validation features include string constraints with min, max, length, email, url, uuid, regex, datetime, and IP address validation, number constraints with min, max, int, positive, negative, and multipleOf, date validation, array constraints with min, max, length, and element type validation, object validation with required and optional keys, strict mode rejecting unknown keys, partial, required, pick, omit, and extend utilities for manipulating object schemas, union and intersection types, discriminated unions for tagged unions, and custom refinements and transforms for domain-specific validation. The error handling provides detailed, structured error messages with paths. The async validation through refine. The discriminated union support. The branded types. The recursive type support through lazy. Designed for TypeScript developers.
Statistics
1
Views
0
Clicks
0
Like
0
Dislike