{"_id":"@cabloy/zod","_rev":"3-36a7798c87cbc538b65c0f4fd44bed94","name":"@cabloy/zod","dist-tags":{"latest":"4.3.8"},"versions":{"4.3.6":{"name":"@cabloy/zod","version":"4.3.6","keywords":["typescript","schema","validation","type","inference"],"author":{"name":"Colin McDonnell","email":"zod@colinhacks.com"},"license":"MIT","_id":"@cabloy/zod@4.3.6","maintainers":[{"name":"zhennann","email":"zhen.nann@icloud.com"}],"homepage":"https://zod.dev","bugs":{"url":"https://github.com/colinhacks/zod/issues"},"dist":{"shasum":"937aeab8bd4f78f1ff2e091bed3b5d3151cc2e4e","tarball":"https://registry.npmjs.org/@cabloy/zod/-/zod-4.3.6.tgz","fileCount":701,"integrity":"sha512-pbN0IZK6BT6bhRp3wGlUVi4zLF5qCm3wspxpXCtOWB8bpQSqi+VgTMb2NGw/NGhlcD83zSyjudBdObqrI+te7w==","signatures":[{"sig":"MEUCIFS3lfalL9rt3eQxyO4t15H7a7xnxSPEP/Utxiq958kXAiEAwxi9+ZqCAAxazm2cPnFPOnFxI2zCUx8aD5R3av+yvRI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4377666},"llms":"https://zod.dev/llms.txt","main":"./index.cjs","type":"module","zshy":{"exports":{".":"./src/index.ts","./v3":"./src/v3/index.ts","./v4":"./src/v4/index.ts","./mini":"./src/mini/index.ts","./locales":"./src/locales/index.ts","./v4-mini":"./src/v4-mini/index.ts","./v4/core":"./src/v4/core/index.ts","./v4/mini":"./src/v4/mini/index.ts","./v4/locales":"./src/v4/locales/index.ts","./package.json":"./package.json","./v4/locales/*":"./src/v4/locales/*"},"conditions":{"@zod/source":"src"}},"types":"./index.d.cts","module":"./index.js","exports":{".":{"types":"./index.d.cts","import":"./index.js","require":"./index.cjs","@zod/source":"./src/index.ts"},"./v3":{"types":"./v3/index.d.cts","import":"./v3/index.js","require":"./v3/index.cjs","@zod/source":"./src/v3/index.ts"},"./v4":{"types":"./v4/index.d.cts","import":"./v4/index.js","require":"./v4/index.cjs","@zod/source":"./src/v4/index.ts"},"./mini":{"types":"./mini/index.d.cts","import":"./mini/index.js","require":"./mini/index.cjs","@zod/source":"./src/mini/index.ts"},"./locales":{"types":"./locales/index.d.cts","import":"./locales/index.js","require":"./locales/index.cjs","@zod/source":"./src/locales/index.ts"},"./v4-mini":{"types":"./v4-mini/index.d.cts","import":"./v4-mini/index.js","require":"./v4-mini/index.cjs","@zod/source":"./src/v4-mini/index.ts"},"./v4/core":{"types":"./v4/core/index.d.cts","import":"./v4/core/index.js","require":"./v4/core/index.cjs","@zod/source":"./src/v4/core/index.ts"},"./v4/mini":{"types":"./v4/mini/index.d.cts","import":"./v4/mini/index.js","require":"./v4/mini/index.cjs","@zod/source":"./src/v4/mini/index.ts"},"./v4/locales":{"types":"./v4/locales/index.d.cts","import":"./v4/locales/index.js","require":"./v4/locales/index.cjs","@zod/source":"./src/v4/locales/index.ts"},"./package.json":"./package.json","./v4/locales/*":{"types":"./v4/locales/*","import":"./v4/locales/*","require":"./v4/locales/*","@zod/source":"./src/v4/locales/*"}},"funding":"https://github.com/sponsors/colinhacks","gitHead":"00b979999a7a9a7e949deb46f7561c84845d3789","scripts":{"test":"pnpm vitest run","build":"zshy --project tsconfig.build.json","clean":"git clean -xdf . -e node_modules","postbuild":"tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .","test:watch":"pnpm vitest","prepublishOnly":"tsx ../../scripts/check-versions.ts"},"support":{"backing":{"npm-funding":true}},"_npmUser":{"name":"zhennann","email":"zhen.nann@icloud.com"},"llmsFull":"https://zod.dev/llms-full.txt","mcpServer":"https://mcp.inkeep.com/zod/mcp","repository":{"url":"git+https://github.com/colinhacks/zod.git","type":"git"},"_npmVersion":"11.6.1","description":"TypeScript-first schema declaration and validation library with static type inference","directories":{},"sideEffects":false,"_nodeVersion":"24.8.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/zod_4.3.6_1776049399505_0.22512466867163572","host":"s3://npm-registry-packages-npm-production"}},"4.3.7":{"name":"@cabloy/zod","version":"4.3.7","keywords":["typescript","schema","validation","type","inference"],"author":{"name":"Colin McDonnell","email":"zod@colinhacks.com"},"license":"MIT","_id":"@cabloy/zod@4.3.7","maintainers":[{"name":"zhennann","email":"zhen.nann@icloud.com"}],"homepage":"https://zod.dev","bugs":{"url":"https://github.com/colinhacks/zod/issues"},"dist":{"shasum":"3fe8d81aacb7b4693445f5ac7d0872e42b642df6","tarball":"https://registry.npmjs.org/@cabloy/zod/-/zod-4.3.7.tgz","fileCount":701,"integrity":"sha512-kGdI3+8SEma+LQz2PxVi9S33568ZRC2ePcMiqif1pDs6eUMrOWnsJTvDucBG0i9sOGEZQjzcurStAA345/61Tg==","signatures":[{"sig":"MEYCIQDOptnUikHu1x6vhgZMs6T+FvDjwfqU9iT0t30ma7AR1gIhAJkkBaels1cawllnMBq7e3Yqq3UCH9maaWl9DtTzHdbu","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4377713},"llms":"https://zod.dev/llms.txt","main":"./index.cjs","type":"module","zshy":{"exports":{".":"./src/index.ts","./v3":"./src/v3/index.ts","./v4":"./src/v4/index.ts","./mini":"./src/mini/index.ts","./locales":"./src/locales/index.ts","./v4-mini":"./src/v4-mini/index.ts","./v4/core":"./src/v4/core/index.ts","./v4/mini":"./src/v4/mini/index.ts","./v4/locales":"./src/v4/locales/index.ts","./package.json":"./package.json","./v4/locales/*":"./src/v4/locales/*"},"conditions":{"@zod/source":"src"}},"_from":"file:cabloy-zod-4.3.7.tgz","types":"./index.d.cts","module":"./index.js","exports":{".":{"types":"./index.d.cts","import":"./index.js","require":"./index.cjs","@zod/source":"./src/index.ts"},"./v3":{"types":"./v3/index.d.cts","import":"./v3/index.js","require":"./v3/index.cjs","@zod/source":"./src/v3/index.ts"},"./v4":{"types":"./v4/index.d.cts","import":"./v4/index.js","require":"./v4/index.cjs","@zod/source":"./src/v4/index.ts"},"./mini":{"types":"./mini/index.d.cts","import":"./mini/index.js","require":"./mini/index.cjs","@zod/source":"./src/mini/index.ts"},"./locales":{"types":"./locales/index.d.cts","import":"./locales/index.js","require":"./locales/index.cjs","@zod/source":"./src/locales/index.ts"},"./v4-mini":{"types":"./v4-mini/index.d.cts","import":"./v4-mini/index.js","require":"./v4-mini/index.cjs","@zod/source":"./src/v4-mini/index.ts"},"./v4/core":{"types":"./v4/core/index.d.cts","import":"./v4/core/index.js","require":"./v4/core/index.cjs","@zod/source":"./src/v4/core/index.ts"},"./v4/mini":{"types":"./v4/mini/index.d.cts","import":"./v4/mini/index.js","require":"./v4/mini/index.cjs","@zod/source":"./src/v4/mini/index.ts"},"./v4/locales":{"types":"./v4/locales/index.d.cts","import":"./v4/locales/index.js","require":"./v4/locales/index.cjs","@zod/source":"./src/v4/locales/index.ts"},"./package.json":"./package.json","./v4/locales/*":{"types":"./v4/locales/*","import":"./v4/locales/*","require":"./v4/locales/*","@zod/source":"./src/v4/locales/*"}},"funding":"https://github.com/sponsors/colinhacks","scripts":{"test":"pnpm vitest run","build":"zshy --project tsconfig.build.json","clean":"git clean -xdf . -e node_modules","postbuild":"tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .","test:watch":"pnpm vitest"},"support":{"backing":{"npm-funding":true}},"_npmUser":{"name":"zhennann","email":"zhen.nann@icloud.com"},"llmsFull":"https://zod.dev/llms-full.txt","_resolved":"/private/var/folders/qy/ds95fdx91vz7rplzrblbdxnr0000gn/T/50d32771be65bd6bd360fbb0b0005ee1/cabloy-zod-4.3.7.tgz","mcpServer":"https://mcp.inkeep.com/zod/mcp","_integrity":"sha512-kGdI3+8SEma+LQz2PxVi9S33568ZRC2ePcMiqif1pDs6eUMrOWnsJTvDucBG0i9sOGEZQjzcurStAA345/61Tg==","repository":{"url":"git+https://github.com/colinhacks/zod.git","type":"git"},"_npmVersion":"11.6.1","description":"TypeScript-first schema declaration and validation library with static type inference","directories":{},"sideEffects":false,"_nodeVersion":"24.8.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/zod_4.3.7_1782378395076_0.488943654061919","host":"s3://npm-registry-packages-npm-production"}},"4.3.8":{"name":"@cabloy/zod","version":"4.3.8","type":"module","license":"MIT","author":{"name":"Colin McDonnell","email":"zod@colinhacks.com"},"description":"TypeScript-first schema declaration and validation library with static type inference","homepage":"https://zod.dev","llms":"https://zod.dev/llms.txt","llmsFull":"https://zod.dev/llms-full.txt","mcpServer":"https://mcp.inkeep.com/zod/mcp","funding":"https://github.com/sponsors/colinhacks","sideEffects":false,"keywords":["typescript","schema","validation","type","inference"],"main":"./index.cjs","types":"./index.d.cts","module":"./index.js","zshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts","./mini":"./src/mini/index.ts","./locales":"./src/locales/index.ts","./v3":"./src/v3/index.ts","./v4":"./src/v4/index.ts","./v4-mini":"./src/v4-mini/index.ts","./v4/mini":"./src/v4/mini/index.ts","./v4/core":"./src/v4/core/index.ts","./v4/locales":"./src/v4/locales/index.ts","./v4/locales/*":"./src/v4/locales/*"},"conditions":{"@zod/source":"src"}},"exports":{"./package.json":"./package.json",".":{"@zod/source":"./src/index.ts","types":"./index.d.cts","import":"./index.js","require":"./index.cjs"},"./mini":{"@zod/source":"./src/mini/index.ts","types":"./mini/index.d.cts","import":"./mini/index.js","require":"./mini/index.cjs"},"./locales":{"@zod/source":"./src/locales/index.ts","types":"./locales/index.d.cts","import":"./locales/index.js","require":"./locales/index.cjs"},"./v3":{"@zod/source":"./src/v3/index.ts","types":"./v3/index.d.cts","import":"./v3/index.js","require":"./v3/index.cjs"},"./v4":{"@zod/source":"./src/v4/index.ts","types":"./v4/index.d.cts","import":"./v4/index.js","require":"./v4/index.cjs"},"./v4-mini":{"@zod/source":"./src/v4-mini/index.ts","types":"./v4-mini/index.d.cts","import":"./v4-mini/index.js","require":"./v4-mini/index.cjs"},"./v4/mini":{"@zod/source":"./src/v4/mini/index.ts","types":"./v4/mini/index.d.cts","import":"./v4/mini/index.js","require":"./v4/mini/index.cjs"},"./v4/core":{"@zod/source":"./src/v4/core/index.ts","types":"./v4/core/index.d.cts","import":"./v4/core/index.js","require":"./v4/core/index.cjs"},"./v4/locales":{"@zod/source":"./src/v4/locales/index.ts","types":"./v4/locales/index.d.cts","import":"./v4/locales/index.js","require":"./v4/locales/index.cjs"},"./v4/locales/*":{"@zod/source":"./src/v4/locales/*","types":"./v4/locales/*","import":"./v4/locales/*","require":"./v4/locales/*"}},"repository":{"type":"git","url":"git+https://github.com/colinhacks/zod.git"},"bugs":{"url":"https://github.com/colinhacks/zod/issues"},"support":{"backing":{"npm-funding":true}},"scripts":{"clean":"git clean -xdf . -e node_modules","build":"zshy --project tsconfig.build.json","postbuild":"tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .","test:watch":"pnpm vitest","test":"pnpm vitest run"},"_id":"@cabloy/zod@4.3.8","_integrity":"sha512-3ik9c1F0VJzQy+/YSnY8DhtDcShgDBmdx+B8j+gFcF+qa6xNK7vyMZ+EYRO2GT7BCucQkTEU/aZBmfEJZcg1Kg==","_resolved":"/private/var/folders/qy/ds95fdx91vz7rplzrblbdxnr0000gn/T/36511a49fe1afd91247647cadb5d6a0b/cabloy-zod-4.3.8.tgz","_from":"file:cabloy-zod-4.3.8.tgz","_nodeVersion":"24.8.0","_npmVersion":"11.6.1","dist":{"integrity":"sha512-3ik9c1F0VJzQy+/YSnY8DhtDcShgDBmdx+B8j+gFcF+qa6xNK7vyMZ+EYRO2GT7BCucQkTEU/aZBmfEJZcg1Kg==","shasum":"8eb9859d87482777c93e553b8043c715b8ad0766","tarball":"https://registry.npmjs.org/@cabloy/zod/-/zod-4.3.8.tgz","fileCount":701,"unpackedSize":4377604,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDyGxzIaQYlnrZ+B7m6ZjdKSO7o+WhqkcbVPW7P1Yc8ZAIgEbXRdgujDN/t9YPjqaAn924xAA2UoNopgpHhwAHvjEw="}]},"_npmUser":{"name":"zhennann","email":"zhen.nann@icloud.com"},"directories":{},"maintainers":[{"name":"zhennann","email":"zhen.nann@icloud.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/zod_4.3.8_1782444042983_0.01831640737784168"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-13T03:03:19.381Z","modified":"2026-06-26T03:20:43.313Z","4.3.6":"2026-04-13T03:03:19.663Z","4.3.7":"2026-06-25T09:06:35.291Z","4.3.8":"2026-06-26T03:20:43.179Z"},"bugs":{"url":"https://github.com/colinhacks/zod/issues"},"author":{"name":"Colin McDonnell","email":"zod@colinhacks.com"},"license":"MIT","homepage":"https://zod.dev","keywords":["typescript","schema","validation","type","inference"],"repository":{"type":"git","url":"git+https://github.com/colinhacks/zod.git"},"description":"TypeScript-first schema declaration and validation library with static type inference","maintainers":[{"name":"zhennann","email":"zhen.nann@icloud.com"}],"readme":"<p align=\"center\">\n  <img src=\"logo.svg\" width=\"200px\" align=\"center\" alt=\"Zod logo\" />\n  <h1 align=\"center\">Zod</h1>\n  <p align=\"center\">\n    TypeScript-first schema validation with static type inference\n    <br/>\n    by <a href=\"https://x.com/colinhacks\">@colinhacks</a>\n  </p>\n</p>\n<br/>\n\n<p align=\"center\">\n<a href=\"https://github.com/colinhacks/zod/actions?query=branch%3Amain\"><img src=\"https://github.com/colinhacks/zod/actions/workflows/test.yml/badge.svg?event=push&branch=main\" alt=\"Zod CI status\" /></a>\n<a href=\"https://opensource.org/licenses/MIT\" rel=\"nofollow\"><img src=\"https://img.shields.io/github/license/colinhacks/zod\" alt=\"License\"></a>\n<a href=\"https://www.npmjs.com/package/zod\" rel=\"nofollow\"><img src=\"https://img.shields.io/npm/dw/zod.svg\" alt=\"npm\"></a>\n<a href=\"https://discord.gg/KaSRdyX2vc\" rel=\"nofollow\"><img src=\"https://img.shields.io/discord/893487829802418277?label=Discord&logo=discord&logoColor=white\" alt=\"discord server\"></a>\n<a href=\"https://github.com/colinhacks/zod\" rel=\"nofollow\"><img src=\"https://img.shields.io/github/stars/colinhacks/zod\" alt=\"stars\"></a>\n</p>\n\n<div align=\"center\">\n  <a href=\"https://zod.dev/api\">Docs</a>\n  <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>\n  <a href=\"https://discord.gg/RcG33DQJdf\">Discord</a>\n  <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>\n  <a href=\"https://twitter.com/colinhacks\">𝕏</a>\n  <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>\n  <a href=\"https://bsky.app/profile/zod.dev\">Bluesky</a>\n  <br />\n</div>\n\n<br/>\n<br/>\n\n<h2 align=\"center\">Featured sponsor: Jazz</h2>\n\n<div align=\"center\">\n  <a href=\"https://jazz.tools/?utm_source=zod\">\n    <picture width=\"85%\" >\n      <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/garden-co/jazz/938f6767e46cdfded60e50d99bf3b533f4809c68/homepage/homepage/public/Zod%20sponsor%20message.png\">\n      <img alt=\"jazz logo\" src=\"https://raw.githubusercontent.com/garden-co/jazz/938f6767e46cdfded60e50d99bf3b533f4809c68/homepage/homepage/public/Zod%20sponsor%20message.png\" width=\"85%\">\n    </picture>\n  </a>\n  <br/>\n  <p><sub>Learn more about <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"mailto:sponsorship@colinhacks.com\">featured sponsorships</a></sub></p>\n</div>\n\n<br/>\n<br/>\n<br/>\n\n### [Read the docs →](https://zod.dev/api)\n\n<br/>\n<br/>\n\n## What is Zod?\n\nZod is a TypeScript-first validation library. Define a schema and parse some data with it. You'll get back a strongly typed, validated result.\n\n```ts\nimport * as z from \"zod\";\n\nconst User = z.object({\n  name: z.string(),\n});\n\n// some untrusted data...\nconst input = {\n  /* stuff */\n};\n\n// the parsed result is validated and type safe!\nconst data = User.parse(input);\n\n// so you can use it with confidence :)\nconsole.log(data.name);\n```\n\n<br/>\n\n## Features\n\n- Zero external dependencies\n- Works in Node.js and all modern browsers\n- Tiny: `2kb` core bundle (gzipped)\n- Immutable API: methods return a new instance\n- Concise interface\n- Works with TypeScript and plain JS\n- Built-in JSON Schema conversion\n- Extensive ecosystem\n\n<br/>\n\n## Installation\n\n```sh\nnpm install zod\n```\n\n<br/>\n\n## Basic usage\n\nBefore you can do anything else, you need to define a schema. For the purposes of this guide, we'll use a simple object schema.\n\n```ts\nimport * as z from \"zod\";\n\nconst Player = z.object({\n  username: z.string(),\n  xp: z.number(),\n});\n```\n\n### Parsing data\n\nGiven any Zod schema, use `.parse` to validate an input. If it's valid, Zod returns a strongly-typed _deep clone_ of the input.\n\n```ts\nPlayer.parse({ username: \"billie\", xp: 100 });\n// => returns { username: \"billie\", xp: 100 }\n```\n\n**Note** — If your schema uses certain asynchronous APIs like `async` [refinements](https://zod.dev/api#refinements) or [transforms](https://zod.dev/api#transforms), you'll need to use the `.parseAsync()` method instead.\n\n```ts\nconst schema = z.string().refine(async (val) => val.length <= 8);\n\nawait schema.parseAsync(\"hello\");\n// => \"hello\"\n```\n\n### Handling errors\n\nWhen validation fails, the `.parse()` method will throw a `ZodError` instance with granular information about the validation issues.\n\n```ts\ntry {\n  Player.parse({ username: 42, xp: \"100\" });\n} catch (err) {\n  if (err instanceof z.ZodError) {\n    err.issues;\n    /* [\n      {\n        expected: 'string',\n        code: 'invalid_type',\n        path: [ 'username' ],\n        message: 'Invalid input: expected string'\n      },\n      {\n        expected: 'number',\n        code: 'invalid_type',\n        path: [ 'xp' ],\n        message: 'Invalid input: expected number'\n      }\n    ] */\n  }\n}\n```\n\nTo avoid a `try/catch` block, you can use the `.safeParse()` method to get back a plain result object containing either the successfully parsed data or a `ZodError`. The result type is a [discriminated union](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions), so you can handle both cases conveniently.\n\n```ts\nconst result = Player.safeParse({ username: 42, xp: \"100\" });\nif (!result.success) {\n  result.error; // ZodError instance\n} else {\n  result.data; // { username: string; xp: number }\n}\n```\n\n**Note** — If your schema uses certain asynchronous APIs like `async` [refinements](https://zod.dev/api#refinements) or [transforms](https://zod.dev/api#transforms), you'll need to use the `.safeParseAsync()` method instead.\n\n```ts\nconst schema = z.string().refine(async (val) => val.length <= 8);\n\nawait schema.safeParseAsync(\"hello\");\n// => { success: true; data: \"hello\" }\n```\n\n### Inferring types\n\nZod infers a static type from your schema definitions. You can extract this type with the `z.infer<>` utility and use it however you like.\n\n```ts\nconst Player = z.object({\n  username: z.string(),\n  xp: z.number(),\n});\n\n// extract the inferred type\ntype Player = z.infer<typeof Player>;\n\n// use it in your code\nconst player: Player = { username: \"billie\", xp: 100 };\n```\n\nIn some cases, the input & output types of a schema can diverge. For instance, the `.transform()` API can convert the input from one type to another. In these cases, you can extract the input and output types independently:\n\n```ts\nconst mySchema = z.string().transform((val) => val.length);\n\ntype MySchemaIn = z.input<typeof mySchema>;\n// => string\n\ntype MySchemaOut = z.output<typeof mySchema>; // equivalent to z.infer<typeof mySchema>\n// number\n```\n","readmeFilename":"README.md"}