{"_id":"zod-prisma-v4","name":"zod-prisma-v4","dist-tags":{"latest":"0.5.4"},"versions":{"0.5.4":{"name":"zod-prisma-v4","version":"0.5.4","description":"A Prisma generator that creates Zod schemas for all of your models","license":"MIT","author":{"name":"Carter Grimmeisen"},"homepage":"https://github.com/leo-paz/zod-prisma-v4#readme","repository":{"type":"git","url":"git+https://github.com/leo-paz/zod-prisma-v4.git"},"bugs":{"url":"https://github.com/leo-paz/zod-prisma-v4/issues"},"main":"dist/index.js","typings":"dist/index.d.ts","bin":{"zod-prisma-v4":"bin/cli.js"},"keywords":["zod","prisma","generator"],"scripts":{"build":"tsup src/index.ts --format cjs --dts --clean --out-dir dist --target node14","lint":"tsc --noEmit","prepublish":"tsup src/index.ts --format cjs --dts --clean --out-dir dist --target node14","test":"node --version && tsc --noEmit"},"prettier":{"printWidth":100,"semi":false,"singleQuote":true,"tabWidth":4,"trailingComma":"es5","useTabs":true},"eslintConfig":{"rules":{"react-hooks/rules-of-hooks":"off"}},"jest":{"testEnvironment":"node"},"dependencies":{"@prisma/generator-helper":"~3.8.1","parenthesis":"^3.1.8","ts-morph":"^13.0.2"},"devDependencies":{"@biomejs/biome":"^1.8.3","@prisma/client":"~3.8.1","@prisma/sdk":"~3.7.0","@tsconfig/recommended":"^1.0.1","@types/fs-extra":"^9.0.13","@types/jest":"^30.0.0","@types/node":"^24.5.2","dts-cli":"^1.1.5","execa":"^5.1.0","fast-glob":"^3.2.5","fs-extra":"^10.0.0","husky":"^7.0.4","jest-mock-extended":"^2.0.4","prisma":"^3.4.2","tslib":"^2.3.1","tsup":"^8.5.0","typescript":"^5.6.3","zod":"^4.1.11"},"peerDependencies":{"decimal.js":"^10.0.0","prisma":"^3.0.0","zod":"^4.0.0"},"peerDependenciesMeta":{"decimal.js":{"optional":true}},"engines":{"node":">=14"},"_id":"zod-prisma-v4@0.5.4","gitHead":"d820b8486d466eb2ddd198c992007b45b403b840","_nodeVersion":"22.16.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-huLjvbmo3SlHQJTP/qDegDd0CI5wM8Y3C31YrGvxQmxrabPoL3S0/0WiJuF3IMJJbsRAb/rvqcgK48HdGBM0GA==","shasum":"bf514239c09fc2c6862b777b5bf35efe6f4ee99b","tarball":"https://registry.npmjs.org/zod-prisma-v4/-/zod-prisma-v4-0.5.4.tgz","fileCount":6,"unpackedSize":10050939,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIB9E8yRv+C14mZOefg4D6Yx/4pwUhDGC587k/1EYc/58AiEA+dc3ZZLh8zWV+mW3aPhOzYlhGhCGCMX5EMTbRJmWxMI="}]},"_npmUser":{"name":"leo.paz","email":"omarleopaz@hotmail.com"},"directories":{},"maintainers":[{"name":"leo.paz","email":"omarleopaz@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/zod-prisma-v4_0.5.4_1758937495846_0.2857168642190522"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-27T01:44:55.762Z","0.5.4":"2025-09-27T01:44:56.154Z","modified":"2025-09-27T01:44:56.444Z"},"maintainers":[{"name":"leo.paz","email":"omarleopaz@hotmail.com"}],"description":"A Prisma generator that creates Zod schemas for all of your models","homepage":"https://github.com/leo-paz/zod-prisma-v4#readme","keywords":["zod","prisma","generator"],"repository":{"type":"git","url":"git+https://github.com/leo-paz/zod-prisma-v4.git"},"author":{"name":"Carter Grimmeisen"},"bugs":{"url":"https://github.com/leo-paz/zod-prisma-v4/issues"},"license":"MIT","readme":"<!--\n*** Thanks for checking out the Best-README-Template. If you have a suggestion\n*** that would make this better, please fork the repo and create a pull request\n*** or simply open an issue with the tag \"enhancement\".\n*** Thanks again! Now go create something AMAZING! :D\n***\n***\n***\n*** To avoid retyping too much info. Do a search and replace for the following:\n*** CarterGrimmeisen, zod-prisma, twitter_handle, Carter.Grimmeisen@uah.edu, Zod Prisma, A custom prisma generator that creates Zod schemas from your Prisma model.\n-->\n\n<!-- PROJECT SHIELDS -->\n<!--\n*** I'm using markdown \"reference style\" links for readability.\n*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).\n*** See the bottom of this document for the declaration of the reference variables\n*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.\n*** https://www.markdownguide.org/basic-syntax/#reference-style-links\n-->\n\n[![NPM][npm-shield]][npm-url]\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n\n<!-- PROJECT LOGO -->\n<br />\n<p align=\"center\">\n  <a href=\"https://github.com/CarterGrimmeisen/zod-prisma\">\n    <img src=\"https://raw.githubusercontent.com/CarterGrimmeisen/zod-prisma/main/images/zod-prisma.svg\" alt=\"Logo\" width=\"120\" height=\"120\">\n  </a>\n  <h3 align=\"center\">Zod Prisma</h3>\n  <p align=\"center\">\n    A custom prisma generator that creates Zod schemas from your Prisma model.\n    <br />\n    <a href=\"https://github.com/CarterGrimmeisen/zod-prisma\"><strong>Explore the docs »</strong></a>\n    <br />\n    <br />\n    <a href=\"https://github.com/CarterGrimmeisen/zod-prisma/blob/main/src/test/functional\">View Demo</a>\n    ·\n    <a href=\"https://github.com/CarterGrimmeisen/zod-prisma/issues\">Report Bug</a>\n    ·\n    <a href=\"https://github.com/CarterGrimmeisen/zod-prisma/issues\">Request Feature</a>\n  </p>\n</p>\n\n<!-- TABLE OF CONTENTS -->\n<details open=\"open\">\n  <summary><h2 style=\"display: inline-block\">Table of Contents</h2></summary>\n  <ol>\n    <li>\n      <a href=\"#about-the-project\">About The Project</a>\n      <ul>\n        <li><a href=\"#built-with\">Built With</a></li>\n      </ul>\n    </li>\n    <li>\n      <a href=\"#getting-started\">Getting Started</a>\n      <ul>\n        <li><a href=\"#prerequisites\">Prerequisites</a></li>\n        <li><a href=\"#installation\">Installation</a></li>\n      </ul>\n    </li>\n    <li><a href=\"#usage\">Usage</a>\n      <ul>\n      <li><a href=\"#jsdoc-generation\">JSDoc Generation</a></li>\n      <li><a href=\"#extending-zod-fields\">Extending Zod Fields</a></li>\n      <li>\n        <a href=\"#importing-helpers\">Importing Helpers</a>\n        <ul>\n        <li><a href=\"#custom-zod-schema\">Custom Zod Schemas</a></li>\n        </ul>\n      </li>\n      <li><a href=\"#json-fields\">JSON Fields</a></li>\n      </ul>\n    </li>\n    <li><a href=\"#examples\">Examples</a></li>\n    <li><a href=\"#roadmap\">Roadmap</a></li>\n    <li><a href=\"#contributing\">Contributing</a></li>\n    <li><a href=\"#license\">License</a></li>\n    <li><a href=\"#contact\">Contact</a></li>\n  </ol>\n</details>\n\n<!-- ABOUT THE PROJECT -->\n\n## About The Project\n\nI got tired of having to manually create Zod schemas for my Prisma models and of updating them everytime I made schema changes.\nThis provides a way of automatically generating them with your prisma\n\n<!-- [![Product Name Screen Shot][product-screenshot]](https://example.com) -->\n\n### Built With\n\n-   [dts-cli](https://github.com/weiran-zsd/dts-cli)\n-   [Zod](https://github.com/colinhacks/zod)\n-   [Based on this gist](https://gist.github.com/deckchairlabs/8a11c33311c01273deec7e739417dbc9)\n\n<!-- GETTING STARTED -->\n\n## Getting Started\n\nTo get a local copy up and running follow these simple steps.\n\n### Prerequisites\n\nThis project utilizes yarn and if you plan on contributing, you should too.\n\n```sh\nnpm install -g yarn\n```\n\n### Installation\n\n0.  **Ensure your tsconfig.json enables the compiler's strict mode.**\n    **Zod requires it and so do we, you will experience TS errors without strict mode enabled**\n\n1.  Add zod-prisma as a dev dependency\n\n    ```sh\n    yarn add -D zod-prisma\n    ```\n\n2.  Add the zod-prisma generator to your schema.prisma\n\n    ```prisma\n    generator zod {\n      provider                 = \"zod-prisma\"\n      output                   = \"./zod\" // (default) the directory where generated zod schemas will be saved\n\n      relationModel            = true // (default) Create and export both plain and related models.\n      // relationModel         = \"default\" // Do not export model without relations.\n      // relationModel         = false // Do not generate related model\n\n      modelCase                = \"PascalCase\" // (default) Output models using pascal case (ex. UserModel, PostModel)\n      // modelCase             = \"camelCase\" // Output models using camel case (ex. userModel, postModel)\n\n      modelSuffix              = \"Model\" // (default) Suffix to apply to your prisma models when naming Zod schemas\n\n      // useDecimalJs          = false // (default) represent the prisma Decimal type using as a JS number\n      useDecimalJs             = true // represent the prisma Decimal type using Decimal.js (as Prisma does)\n\n      imports                  = null // (default) will import the referenced file in generated schemas to be used via imports.someExportedVariable\n\n      // https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-by-null-values\n      prismaJsonNullability    = true // (default) uses prisma's scheme for JSON field nullability\n      // prismaJsonNullability = false // allows null assignment to optional JSON fields\n    }\n    ```\n\n3.  Run `npx prisma generate` or `yarn prisma generate` to generate your zod schemas\n4.  Import the generated schemas form your selected output location\n\n<!-- USAGE EXAMPLES -->\n\n## Usage\n\n### JSDoc Generation\n\n[Rich-comments](https://www.prisma.io/docs/concepts/components/prisma-schema#comments)\nin the Prisma schema will be transformed into JSDoc for the associated fields:\n\n> _Note: make sure to use a triple-slash. Double-slash comments won't be processed._\n\n```prisma\nmodel Post {\n  /// The unique identifier for the post\n  /// @default {Generated by database}\n  id String @id @default(uuid())\n\n  /// A brief title that describes the contents of the post\n  title String\n\n  /// The actual contents of the post.\n  contents String\n}\n```\n\nGenerated code:\n\n```ts\nexport const PostModel = z.object({\n\t/**\n\t * The unique identifier for the post\n\t * @default {Generated by database}\n\t */\n\tid: z.string().uuid(),\n\t/**\n\t * A brief title that describes the contents of the post\n\t */\n\ttitle: z.string(),\n\t/**\n\t * The actual contents of the post.\n\t */\n\tcontents: z.string(),\n})\n```\n\n### Extending Zod Fields\n\nYou can also use the `@zod` keyword in rich-comments in the Prisma schema\nto extend your Zod schema fields:\n\n```prisma\nmodel Post {\n  id String @id @default(uuid()) /// @zod.uuid()\n\n  /// @zod.max(255, { message: \"The title must be shorter than 256 characters\" })\n  title String\n\n  contents String /// @zod.max(10240)\n}\n```\n\nGenerated code:\n\n```ts\nexport const PostModel = z.object({\n\tid: z.string().uuid(),\n\ttitle: z.string().max(255, { message: 'The title must be shorter than 256 characters' }),\n\tcontents: z.string().max(10240),\n})\n```\n\n### Importing Helpers\n\nSometimes its useful to define a custom Zod preprocessor or transformer for your data.\nzod-prisma enables you to reuse these by importing them via a config options. For example:\n\n```prisma\ngenerator zod {\n  provider      = \"zod-prisma\"\n  output        = \"./zod\"\n  imports \t\t  = \"../src/zod-schemas\"\n}\n\nmodel User {\n  username\tString /// @zod.refine(imports.isValidUsername)\n}\n```\n\nThe referenced file can then be used by simply referring to exported members via `imports.whateverExport`.\nThe generated zod schema files will now include a namespaced import like the following.\n\n```typescript\nimport * as imports from '../../src/zod-schemas'\n```\n\n#### Custom Zod Schema\n\nIn conjunction with this import option, you may want to utilize an entirely custom zod schema for a field.\nThis can be accomplished by using the special comment directive `@zod.custom()`.\nBy specifying the custom schema within the parentheses you can replace the autogenerated type that would normally be assigned to the field.\n\n> For instance if you wanted to use `z.preprocess`\n\n### JSON Fields\n\nJSON fields in Prisma disallow null values. This is to disambiguate between setting a field's value to NULL in the database and having\na value of null stored in the JSON. In accordance with this zod-prisma will default to disallowing null values, even if your JSON field is optional.\n\nIf you would like to revert this behavior and allow null assignment to JSON fields,\nyou can set `prismaJsonNullability` to `false` in the generator options.\n\n## Examples\n\n<!-- Use this space to show useful examples of how a project can be used. Additional screenshots, code examples and demos work well in this space. You may also link to more resources. -->\n\n_For examples, please refer to the [Examples Directory](https://github.com/CarterGrimmeisen/zod-prisma/blob/main/examples) or the [Functional Tests](https://github.com/CarterGrimmeisen/zod-prisma/blob/main/src/test/functional)_\n\n<!-- ROADMAP -->\n\n## Roadmap\n\nSee the [open issues](https://github.com/CarterGrimmeisen/zod-prisma/issues) for a list of proposed features (and known issues).\n\n<!-- CONTRIBUTING -->\n\n## Contributing\n\nContributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n<!-- LICENSE -->\n\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n\n<!-- CONTACT -->\n\n## Contact\n\nCarter Grimmeisen - Carter.Grimmeisen@uah.edu\n\nProject Link: [https://github.com/CarterGrimmeisen/zod-prisma](https://github.com/CarterGrimmeisen/zod-prisma)\n\n<!-- MARKDOWN LINKS & IMAGES -->\n<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->\n\n[npm-shield]: https://img.shields.io/npm/v/zod-prisma?style=for-the-badge\n[npm-url]: https://www.npmjs.com/package/zod-prisma\n[contributors-shield]: https://img.shields.io/github/contributors/CarterGrimmeisen/zod-prisma.svg?style=for-the-badge\n[contributors-url]: https://github.com/CarterGrimmeisen/zod-prisma/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/CarterGrimmeisen/zod-prisma.svg?style=for-the-badge\n[forks-url]: https://github.com/CarterGrimmeisen/zod-prisma/network/members\n[stars-shield]: https://img.shields.io/github/stars/CarterGrimmeisen/zod-prisma.svg?style=for-the-badge\n[stars-url]: https://github.com/CarterGrimmeisen/zod-prisma/stargazers\n[issues-shield]: https://img.shields.io/github/issues/CarterGrimmeisen/zod-prisma.svg?style=for-the-badge\n[issues-url]: https://github.com/CarterGrimmeisen/zod-prisma/issues\n[license-shield]: https://img.shields.io/github/license/CarterGrimmeisen/zod-prisma.svg?style=for-the-badge\n[license-url]: https://github.com/CarterGrimmeisen/zod-prisma/blob/main/LICENSE\n","readmeFilename":"README.md","_rev":"1-0cc4ad57aafdc98754adad603b205a8b"}