{"name":"zod-validation-error","version":"0.2.2-beta.1","description":"Wrap zod validation errors in user-friendly readable messages","keywords":["zod","error","validation"],"license":"MIT","repository":{"type":"git","url":"git://github.com/causaly/zod-validation-error.git"},"author":{"name":"Causaly Team","email":"front-end@causaly.com","url":"https://www.causaly.com"},"contributors":[{"name":"Dimitrios C. Michalakos","email":"dimitris@jmike.gr","url":"https://github.com/jmike"}],"main":"./dist/cjs/index.js","module":"./dist/esm/index.js","types":"./dist/types/index.d.ts","publishConfig":{"access":"public"},"sideEffects":false,"engines":{"node":"^14.17 || >=16.0.0"},"scripts":{"typecheck":"tsc --noEmit","build:cjs":"tsc -p ./tsconfig.build-cjs.json","build:esm":"tsc -p ./tsconfig.build-esm.json","build:types":"tsc -p ./tsconfig.build-types.json","build":"rimraf dist && concurrently \"yarn build:types\" \"yarn build:esm\" \"yarn build:cjs\"","lint":"eslint lib --ext .ts","format":"prettier --config ./.prettierrc --ignore-path .gitignore -w .","test":"jest --config ./config/jest.config.ts","coverage":"jest --config jest.config.ts --coverage","changeset":"changeset","prerelease":"yarn build && yarn test","release":"changeset publish"},"husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS","pre-commit":"lint-staged"}},"lint-staged":{"*.{js,jsx,ts,tsx}":["eslint --fix","prettier --config ./.prettierrc --write"]},"devDependencies":{"@changesets/changelog-github":"^0.4.2","@changesets/cli":"^2.18.1","@commitlint/cli":"^15.0.0","@commitlint/config-conventional":"^15.0.0","@types/jest":"^27.0.3","@types/node":"^17.0.0","@typescript-eslint/eslint-plugin":"^5.7.0","@typescript-eslint/parser":"^5.7.0","concurrently":"^6.5.1","eslint":"^8.4.1","eslint-config-prettier":"^8.1.0","eslint-plugin-prettier":"^4.0.0","eslint-plugin-simple-import-sort":"^7.0.0","husky":"4","jest":"^27.0.6","lint-staged":"^12.1.2","prettier":"^2.2.1","rimraf":"^3.0.0","ts-jest":"^27.0.5","typescript":"^4.2.3","zod":"^3.18.0"},"peerDependencies":{"zod":"^3.18.0"},"readmeFilename":"README.md","readme":"# zod-validation-error\n\nWrap zod validation errors in user-friendly readable messages.\n\n[![Build Status](https://github.com/causaly/zod-validation-error/actions/workflows/ci.yml/badge.svg)](https://github.com/causaly/zod-validation-error/actions/workflows/ci.yml) [![npm version](https://img.shields.io/npm/v/zod-validation-error.svg?color=0c0)](https://www.npmjs.com/package/zod-validation-error)\n\n#### Features\n\n- User-friendly readable messages, configurable via options;\n- Maintain original errors under `error.details`;\n- Extensive tests.\n\n## Installation\n\n```bash\nnpm install zod-validation-error\n```\n\n#### Requirements\n\n- Node.js v.14+\n\n## Quick start\n\n```typescript\n// create zod schema\nconst zodSchema = zod.object({\n  id: zod.number().int().positive(),\n  email: zod.string().email(),\n});\n\n// parse some invalid value\ntry {\n  zodSchema.parse({\n    id: 1,\n    email: 'foobar', // note: invalid email\n  });\n} catch (err) {\n  const validationError = fromZodError(err);\n  // the error now is readable by the user\n  // you may print it to console\n  // or return it via an API\n  console.log(validationError);\n}\n```\n\n## Motivation\n\nZod errors are difficult to consume for the end-user. This library wraps Zod validation errors in user-friendly readable messages that can be exposed to the outer world, while maintaining the original errors in an array for _dev_ use.\n\n### Example\n\n#### Input (from Zod)\n\n```json\n[\n  {\n    \"code\": \"too_small\",\n    \"inclusive\": false,\n    \"message\": \"Number must be greater than 0\",\n    \"minimum\": 0,\n    \"path\": [\"id\"],\n    \"type\": \"number\"\n  },\n  {\n    \"code\": \"invalid_string\",\n    \"message\": \"Invalid email\",\n    \"path\": [\"email\"],\n    \"validation\": \"email\"\n  }\n]\n```\n\n#### Output\n\n```\nValidation error: Number must be greater than 0 at \"id\"; Invalid email at \"email\"\n```\n\n## Contribute\n\nSource code contributions are most welcome. Please open a PR, ensure the linter is satisfied and all tests pass.\n\n#### We are hiring\n\nCausaly is building the world's largest biomedical knowledge platform, using technologies such as TypeScript, React and Node.js. Find out more about our openings at https://apply.workable.com/causaly/.\n\n## License\n\nMIT\n","licenseText":"(The MIT License)\n\nCopyright 2022 Causaly, Inc <front-end@causaly.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_id":"zod-validation-error@0.2.2-beta.1","dist":{"shasum":"fcd3f57f242796081c077dc4c33933d0d1a4ad07","integrity":"sha512-iUIR6h935RWAIN0+qO86tySSz+eRz2uvfA4tlnvUC1WXFvctBJN6Ye67vf/3thY1tVgxMgr7l5vN/BgOnvRy4Q==","tarball":"http://registry-npm.ywwl.com/zod-validation-error/download/zod-validation-error-0.2.2-beta.1.tgz","fileCount":24,"unpackedSize":12620,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEmaHSpgUBx8hCOKkct75pTijT2MC5KBqScg4dTEk6s4AiApv1/7jm/JHgTcjcL2mQATSVJK7O83FY5ZYZ/RlmVC2g=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjlyAXACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoruQ/8DR4RSIuPxTNkGPRFddS0AuMGmuZVkhl1WiTK6R8sqU7VUhhq\r\n/ZzgtP0h1cRk9/Rpcj/mXwfXutA65udvYuynPrj3dvRWRfaj2ARCYMosrvTS\r\ndZMxGjxk8Q6w6R2xFgTzl8m3LJwlV2o/tNUgIPEKLd4h7yMObCxsYi06eucB\r\nQbHZFPV/OOGVoQMKIx3gvEAY761NOcl5mRwdEX7K7wn7fj1zErcPfN5O5Sjh\r\noSbBj77twrozILsNG0/UQWZg7/kyDPYekSWoFop0LcXIb7OIVzIOA+pgamLT\r\nXHedjd7ek02ls087ELEP/HOFvmCrfpfiEVJbsXhIBFqm1vBAfSAEayhSafWg\r\n5DjS29guTD0c+LuVbrDIlkkIay8Ix3VEOlWxDKUGtI3O3D5Gv3fyaHZW2xVS\r\nN+hz50saeNKhK3Wmb6P5lym0RxBpFGwjQ4EFC+7JsFdeDd3fep78RM6JbY8b\r\nHa2CFmxeXZ8wU/eW4PNq5Sf+gSbbTyqw/bFLI9X3mT++lggai8+C1vMeo19+\r\nWY0OK0wDpEOOat6EjZ0BTAz9/5hb6E+H0n8W5XMAMpbOlkRMwsUcUzSMMrD3\r\ngsSC7MTXGQKvN2z+CGHJN4jyxH+hW0jbelhUp35UzFLtAeoYove+MFyIE5DA\r\nIsC8lUHqB3VGHBDhOBvF0+fUjfWYhWtUjog=\r\n=OFHf\r\n-----END PGP SIGNATURE-----\r\n","size":4838,"noattachment":false,"key":"/zod-validation-error/-/zod-validation-error-0.2.2-beta.1.tgz"},"_npmUser":{"name":"dnlytras","email":"dnlytras@gmail.com"},"directories":{},"maintainers":[{"name":"nikoskalogridis","email":"nikos.kalogridis@gmail.com"},{"name":"dnlytras","email":"dnlytras@gmail.com"},{"name":"jmike","email":"dimitris@jmike.gr"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zod-validation-error_0.2.2-beta.1_1670848535361_0.27771568340391783"},"_hasShrinkwrap":false,"publish_time":1670848535538,"_cnpm_publish_time":1670848535538,"dist-tags":{"beta":"4.0.0-beta.2","latest":"5.0.0"}}