zod-compiler
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

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.

Package Sidebar

Install

npm i zod-compiler

Weekly Downloads

7

Version

0.1.1

License

MIT OR Apache-2.0

Unpacked Size

333 kB

Total Files

8

Last publish

Collaborators

  • decahedron1