Skip to content

Speed up your Zod schemas / export TypeScript definitions

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

pykeio/zod-compiler

Repository files navigation

zod-compiler

Speed up your Zod schemas

import z from 'zod';

const schema = z.object({
	title: z.string().min(3).max(64),
	tags: z.array(z.string()).optional(),
	...
});

// ❌ slow!
const { success, data, error } = schema.safeParse(input);

// 🚀
import zc from 'zod-compiler';
const compiledSchema = zc.compile(schema);

const { success, data, error } = compiledSchema.safeParse(input);

Export your Zod schemas to TypeScript types

console.log(zc.types(schema));
// export type Schema = {
//     title: string;
//     tags?: string[];
//     ...
// };

Installation

$ npm i --save zod-compiler

Requires Zod 3.x and TypeScript 5.x to be installed.

About

Speed up your Zod schemas / export TypeScript definitions

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks