(Translated by https://www.hiragana.jp/)
GitHub - KATT/zod: TypeScript-first schema validation with static type inference
Skip to content
/ zod Public
forked from colinhacks/zod

TypeScript-first schema validation with static type inference

License

Notifications You must be signed in to change notification settings

KATT/zod

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zod logo

Zod

https://zod.dev
TypeScript-first schema validation with static type inference


Zod CI status Created by Colin McDonnell License npm stars discord server

Documentation   •   Discord   •   npm   •   deno   •   Issues   •   @colinhacks   •   tRPC


These docs have been translated into Chinese.

Table of contents

Introduction

Zod is a TypeScript-first schema declaration and validation library. I'm using the term "schema" to broadly refer to any data type, from a simple string to a complex nested object.

Zod is designed to be as developer-friendly as possible. The goal is to eliminate duplicative type declarations. With Zod, you declare a validator once and Zod will automatically infer the static TypeScript type. It's easy to compose simpler types into complex data structures.

Some other great aspects:

  • Zero dependencies
  • Works in Node.js and all modern browsers
  • Tiny: 8kb minified + zipped
  • Immutable: methods (e.g. .optional()) return a new instance
  • Concise, chainable interface
  • Functional approach: parse, don't validate
  • Works with plain JavaScript too! You don't need to use TypeScript.

Sponsors

Sponsorship at any level is appreciated and encouraged. For individual developers, consider the Cup of Coffee tier. If you built a paid product using Zod, consider one of the podium tiers.

Gold

Speakeasy API
Speakeasy
speakeasyapi.dev

SDKs, Terraform, Docs.
Your API made enterprise-ready

Deletype logo
Deletype
deletype.com
Trigger.dev logo
Trigger.dev
trigger.dev

Effortless automation for developers

Transloadit logo
Transloadit
transloadit.com

Simple file processing for developers

Infisical logo
Infisical
infisical.com

Open-source platform for secret
management: sync secrets across your
team/infrastructure and prevent secret leaks

Whop logo
Whop
whop.com

A marketplace for really cool internet products

CryptoJobsList logo
CryptoJobsList
cryptojobslist.com

The biggest list of crypto, blockchain and Web3 jobs

Plain logo
Plain.
plain.com

How developers support their users

Inngest logo
Inngest
inngest.com

Serverless queues + durable workflows for TypeScript

Storyblok CMS
Storyblok
storyblok.com

The only headless CMS with a visual editor

Mux logo
Mux
mux.com

The internet's video infrastructure

Silver

Numeric logo
Numeric
numeric.io
Marcato Partners
Marcato Partners
marcatopartners.com

Interval
interval.com

Seasoned Software
seasoned.cc
Bamboo Creative logo
Bamboo Creative
bamboocreative.nz

Bronze


Brandon Bayer
@flybayer, creator of Blitz.js

Jiří Brabec
@brabeji

Alex Johansson
@alexdotjs
Fungible Systems logo
Fungible Systems
fungible.systems

Adaptable
adaptable.io
Avana Wallet logo
Avana Wallet
avanawallet.com
Solana non-custodial wallet
Learn with Jason logo
Jason Lengstorf
learnwithjason.dev
Global Illumination
Global Illumination, Inc.
ill.inc
MasterBorn logo
MasterBorn
masterborn.com
Ryan Palmer
Ryan Palmer
@kronodeus
Michael Sweeney
Michael Sweeney
@overthemike
Nextbase logo
Nextbase
usenextbase.com
Remotion logo
Remotion
remotion.dev
Connor Sinnott profile
Connor Sinnott
@ConnorSinnott
aerabi
Mohammad-Ali A'râbi
aerabi.com
Supatool logo
Supatool
supatool.io

Ecosystem

There are a growing number of tools that are built atop or support Zod natively! If you've built a tool or library on top of Zod, tell me about it on Twitter or start a Discussion. I'll add it below and tweet it out.

Resources

API libraries

  • tRPC: Build end-to-end typesafe APIs without GraphQL.
  • @anatine/zod-nestjs: Helper methods for using Zod in a NestJS project.
  • zod-endpoints: Contract-first strictly typed endpoints with Zod. OpenAPI compatible.
  • zhttp: An OpenAPI compatible, strictly typed http library with Zod input and response validation.
  • domain-functions: Decouple your business logic from your framework using composable functions. With first-class type inference from end to end powered by Zod schemas.
  • @zodios/core: A typescript API client with runtime and compile time validation backed by axios and zod.
  • express-zod-api: Build Express-based APIs with I/O schema validation and custom middlewares.
  • tapiduck: End-to-end typesafe JSON APIs with Zod and Express; a bit like tRPC, but simpler.
  • koa-zod-router: Create typesafe routes in Koa with I/O validation using Zod.

Form integrations

  • react-hook-form: A first-party Zod resolver for React Hook Form.
  • zod-validation-error: Generate user-friendly error messages from ZodErrors.
  • zod-formik-adapter: A community-maintained Formik adapter for Zod.
  • react-zorm: Standalone <form> generation and validation for React using Zod.
  • zodix: Zod utilities for FormData and URLSearchParams in Remix loaders and actions.
  • conform: A typesafe form validation library for progressive enhancement of HTML forms. Works with Remix and Next.js.
  • remix-params-helper: Simplify integration of Zod with standard URLSearchParams and FormData for Remix apps.
  • formik-validator-zod: Formik-compliant validator library that simplifies using Zod with Formik.
  • zod-i18n-map: Useful for translating Zod error messages.
  • @modular-forms/solid: Modular form library for SolidJS that supports Zod for validation.
  • houseform: A React form library that uses Zod for validation.
  • sveltekit-superforms: Supercharged form library for SvelteKit with Zod validation.
  • mobx-zod-form: Data-first form builder based on MobX & Zod.
  • @vee-validate/zod: Form library for Vue.js with Zod schema validation.

Zod to X