{"_id":"@ata-project/zod","_rev":"3-f3658f5baf691a88013efa4cae7da194","name":"@ata-project/zod","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.0":{"name":"@ata-project/zod","version":"0.1.0","keywords":["zod","ata-validator","json-schema","validation","standard-schema"],"license":"MIT","_id":"@ata-project/zod@0.1.0","maintainers":[{"name":"mertcanaltin","email":"mertgold60@gmail.com"}],"homepage":"https://github.com/ata-core/ata-zod#readme","bugs":{"url":"https://github.com/ata-core/ata-zod/issues"},"dist":{"shasum":"60b82129a6a13af4fd088bcb46f8217c097964cf","tarball":"https://registry.npmjs.org/@ata-project/zod/-/zod-0.1.0.tgz","fileCount":5,"integrity":"sha512-jtYKpsgxllhdqRdWUagseyfaEwiOR3UMBmGpzBec+O3AQkLBpyAtFBo3rNZoFHrac7EtRLw/IV2Vw3JUdYGVPA==","signatures":[{"sig":"MEUCICqftjS1ZY0uTFd+17bh8z0xqcVh/e/5MKnCgWlTJ0U6AiEAljSlpzUPgLMx2N1kJ53kW5civzGBJ4s5XNWODDX324c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17599},"main":"index.js","types":"index.d.ts","gitHead":"3630f3044243862ff06e3c1a0a36e1bab047bb58","scripts":{"test":"node test.js && node --disallow-code-generation-from-strings test.js && npm run test:types","bench":"node bench.mjs","test:types":"tsc --noEmit -p tsconfig.json"},"_npmUser":{"name":"mertcanaltin","email":"mertgold60@gmail.com"},"repository":{"url":"git+https://github.com/ata-core/ata-zod.git","type":"git"},"_npmVersion":"11.19.0","description":"Run zod schemas on the ata engine: same answers as zod, verdicts decided by compiled JSON Schema validation, refinements handed back to zod.","directories":{},"_nodeVersion":"25.2.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"zod":"^4.5.4","typescript":"^7.0.2","@types/node":"^26.4.1","ata-validator":"^1.13.0"},"peerDependencies":{"zod":"^4.1.0","ata-validator":">=1.12.1"},"_npmOperationalInternal":{"tmp":"tmp/zod_0.1.0_1788698020568_0.7872999029469934","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@ata-project/zod","version":"0.2.0","keywords":["zod","ata-validator","json-schema","validation","standard-schema"],"license":"MIT","_id":"@ata-project/zod@0.2.0","maintainers":[{"name":"mertcanaltin","email":"mertgold60@gmail.com"}],"homepage":"https://github.com/ata-core/ata-zod#readme","bugs":{"url":"https://github.com/ata-core/ata-zod/issues"},"dist":{"shasum":"fb08cca47efd9d415cd727a65cd31a435918284c","tarball":"https://registry.npmjs.org/@ata-project/zod/-/zod-0.2.0.tgz","fileCount":5,"integrity":"sha512-K5gteJkAPnc6ynXjOupBa/wQgJpRLV5qJF2S7Ur6dPYhTSSDfM5OzfpfbM2qUy54muNvi6e4Qz4wjGnxMh8JGw==","signatures":[{"sig":"MEUCIQCdIARzpoRhxlQTAfYFdW09NV7Y71Sq2pR/xT7lfZZztAIgXMt85AGN3LjyDCX+7JJ1OFLL4/rf7Ek5+ISNA8SlNnY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20498},"main":"index.js","types":"index.d.ts","gitHead":"a9c8dd4b41b205215a96f32043c6052b8ee9bce1","scripts":{"test":"node test.js && node --disallow-code-generation-from-strings test.js && npm run test:types","bench":"node bench.mjs","test:types":"tsc --noEmit -p tsconfig.json"},"_npmUser":{"name":"mertcanaltin","email":"mertgold60@gmail.com"},"repository":{"url":"git+https://github.com/ata-core/ata-zod.git","type":"git"},"_npmVersion":"11.19.0","description":"Run zod schemas on the ata engine: same answers as zod, verdicts decided by compiled JSON Schema validation, refinements handed back to zod.","directories":{},"_nodeVersion":"25.2.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"zod":"^4.5.4","typescript":"^7.0.2","@types/node":"^26.4.1","ata-validator":"^1.13.1"},"peerDependencies":{"zod":"^4.1.0","ata-validator":">=1.12.1"},"_npmOperationalInternal":{"tmp":"tmp/zod_0.2.0_1788710874843_0.5757411235299466","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"_id":"@ata-project/zod@0.2.1","bugs":{"url":"https://github.com/ata-core/ata-zod/issues"},"dist":{"shasum":"bed25344135518a68d9ebc5bf8076bef46484dec","tarball":"https://registry.npmjs.org/@ata-project/zod/-/zod-0.2.1.tgz","fileCount":5,"integrity":"sha512-TuWy9pwt4zQRSUCOZXTUPW0VR8ypFbfnIRwswxQO1sEyhiwkvhLFErsvxh3gOBiBITQFSvQV1ijxPGjLmYOP6w==","signatures":[{"sig":"MEQCIHsUyVt5rooXFoRN0a0TZsmJyistO25oiBI7411OE0PnAiB1++Wnxp1Bt4Nw8azVSz6aHy/z0inwUaUEw7Mj3ZHUHw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCcSfL32YyThLpaLREnAUfEZefjgYzjIL5KcsPw0+EVxAIhAOytcIGg/CNKmAozTo2EEV3EoizMyHg1xqo+BQRsjkWK"}],"unpackedSize":20550},"main":"index.js","name":"@ata-project/zod","types":"index.d.ts","gitHead":"ddc265585ec9b4341065a4033ffc9a7e9e33d4ce","license":"MIT","scripts":{"test":"node test.js && node --disallow-code-generation-from-strings test.js && npm run test:types","bench":"node bench.mjs","test:types":"tsc --noEmit -p tsconfig.json"},"version":"0.2.1","_npmUser":{"name":"mertcanaltin","email":"mertgold60@gmail.com"},"homepage":"https://github.com/ata-core/ata-zod#readme","keywords":["zod","ata-validator","json-schema","validation","standard-schema"],"repository":{"url":"git+https://github.com/ata-core/ata-zod.git","type":"git"},"_npmVersion":"11.19.0","description":"Run zod schemas on the ata engine: same answers as zod, verdicts decided by compiled JSON Schema validation, refinements handed back to zod.","directories":{},"maintainers":[{"name":"mertcanaltin","email":"mertgold60@gmail.com"}],"_nodeVersion":"25.2.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"zod":"^4.6.5","typescript":"^7.0.2","@types/node":"^26.4.1","ata-validator":"^1.25.0"},"peerDependencies":{"zod":"^4.1.0","ata-validator":">=1.12.1"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/zod_0.2.1_1789637597659_0.32622127590256933"}}},"time":{"created":"2026-09-06T12:33:40.375Z","modified":"2026-09-17T09:33:17.957Z","0.1.0":"2026-09-06T12:33:40.712Z","0.2.0":"2026-09-06T16:07:54.975Z","0.2.1":"2026-09-17T09:33:17.768Z"},"bugs":{"url":"https://github.com/ata-core/ata-zod/issues"},"license":"MIT","homepage":"https://github.com/ata-core/ata-zod#readme","keywords":["zod","ata-validator","json-schema","validation","standard-schema"],"repository":{"url":"git+https://github.com/ata-core/ata-zod.git","type":"git"},"description":"Run zod schemas on the ata engine: same answers as zod, verdicts decided by compiled JSON Schema validation, refinements handed back to zod.","maintainers":[{"name":"mertcanaltin","email":"mertgold60@gmail.com"}],"readme":"# @ata-project/zod\n\nRun zod schemas on the [ata](https://github.com/ata-core/ata-validator) engine.\nThe schema stays zod. The verdict comes from compiled JSON Schema validation\nwhere that is provably safe, and from zod itself everywhere it is not.\n\n```sh\nnpm i @ata-project/zod\n```\n\nzod 4 and ata-validator are peer dependencies; npm and pnpm install them\nautomatically, yarn users add them alongside.\n\n![One zod schema, three ways to run it: measured times for accepting and rejecting documents, in Node and with code generation blocked](https://raw.githubusercontent.com/ata-core/ata-zod/main/assets/bench.png)\n\n```js\nimport { z } from 'zod'\nimport { compile } from '@ata-project/zod'\n\nconst user = z.object({\n  id: z.number().int().min(1),\n  name: z.string().min(1).max(64),\n  email: z.string().email(),\n})\n\nconst check = compile(user)\n\ncheck.isValid(data)      // boolean, ata answers\ncheck.safeParse(data)    // zod-shaped result, zod-produced value\ncheck.parse(data)        // throws a real ZodError\n```\n\nTypes carry through: `safeParse` returns `z.output` of your schema.\n\n## How it stays correct\n\nzod 4 turns a schema into JSON Schema with `z.toJSONSchema`, and ata executes\nJSON Schema. That conversion is lossy in both directions: refinements and\ntransforms are dropped silently, which makes the emitted schema looser than\nzod, and coercion is dropped too, which makes it stricter. A wrong answer in\neither direction is unacceptable, so `compile` classifies the schema by\nwalking zod's own definition tree before anything runs:\n\n| Mode | When | Who answers |\n|---|---|---|\n| `ata` | the conversion is exact | ata alone |\n| `hybrid` | refine, transform, pipe, Date and other non-JSON types | ata's rejection is final; an acceptance runs zod for the residue |\n| `zod` | coerce, catch, preprocess, or a node this package does not recognise | zod, undecorated |\n\nThe classification is conservative: an unrecognised node lands in `zod` mode,\nso a new zod feature can make this package slower, never wrong. The test suite\nholds `isValid`, `safeParse` and the parsed value against zod itself over\n13,000 generated values across all three modes, including recursive schemas,\nand runs the whole suite a second time with code generation blocked.\n\n`compiled.engine` tells you which mode you got, `compiled.reasons` says why.\n\n## What it costs, measured\n\nOne representative API-boundary object schema (nine fields, nested arrays of\nobjects, enum, union), interleaved medians of 7 rounds on an M-series Mac,\nNode 25, zod 4.6.5, ata-validator 1.25.0:\n\n| | zod `safeParse` | `z.compile` | this package |\n|---|---|---|---|\n| accept, verdict only | 512 ns | 43 ns | **20 ns** |\n| reject, verdict only | 811 ns | 823 ns | **5 ns** |\n| reject, `safeParse` | 811 ns | 823 ns | **6.5 ns** |\n| accept, `safeParse` | 512 ns | 43 ns | 518 ns |\n\nThe last row is by design, not a gap: an accepted value's output is zod's to\nmake. Plain `z.object` strips unknown keys, defaults fill, transforms rewrite,\nso `safeParse` hands every accepted value to zod and returns exactly what zod\nreturns. What this package owns is the verdict and the rejection: `isValid`\nnever runs zod in `ata` mode, and a rejected `safeParse` builds its `ZodError`\nonly when somebody reads it, by running zod once at that moment.\n\nWith code generation blocked, the way a strict CSP or a locked-down edge\nruntime blocks it (`node --disallow-code-generation-from-strings`):\n\n| | zod `safeParse` | `z.compile` | this package |\n|---|---|---|---|\n| accept, verdict only | 1260 ns | 1245 ns | **644 ns** |\n| reject, verdict only | 1651 ns | 1675 ns | **107 ns** |\n\n`z.compile` does not fail there, but its advantage does: it runs at the speed\nof uncompiled zod. ata falls back to its interpreted engine, which passes the\nsame official JSON Schema test suite as its compiled one.\n\n## Raw bytes\n\n`isValidBytes` answers from a `Buffer`, `Uint8Array` or JSON string without\n`JSON.parse` and without materializing a JavaScript object, something zod has\nno path for at all:\n\n```js\nconst check = compile(schema)\ncheck.isValidBytes(request.rawBody)   // boolean, straight from the bytes\n```\n\nOn an `engine: 'ata'` schema with the native engine present, the verdict comes\nfrom a SIMD walk of the buffer. The same array-of-objects schema as above,\ninterleaved medians of 7 rounds, first element invalid on the reject rows,\nmeasured on zod 4.5.4 and ata-validator 1.13.1:\n\n| payload | zod parse + safeParse | `isValidBytes` |\n|---|---|---|\n| 0.2 KB, accept | 0.9 us | **0.6 us** |\n| 0.2 KB, reject | 1.6 us | **0.6 us** |\n| 22.7 KB, accept | 79.2 us | **47.6 us** |\n| 22.7 KB, reject | 81.0 us | **45.6 us** |\n| 229 KB, accept | 793 us | **489 us** |\n| 229 KB, reject | 791 us | **482 us** |\n\nBytes that are not valid JSON return `false` rather than throwing. The verdict\nagrees with `safeParse` on the parsed value; the differential suite compares\nthe two on every JSON-representable value it generates.\n\nPlainly: this is a verdict, not a parse. When you need the value, you still\nparse and `safeParse` it, and `hybrid` and `zod` mode schemas, and installs\nwithout the native engine, do exactly that under the hood. The API is worth\nhaving where rejection is the common case: gateways, webhook endpoints and\nqueue consumers that drop bad messages before doing any further work.\n\n## Limitations, plainly\n\n- Accepted values in `hybrid` mode and every value in `zod` mode run zod, so\n  those paths are zod-speed. The win is the rejection and the pure-schema case.\n- `validate()` reports ata's errors for the schema-representable part, which\n  are JSON Schema errors, not `ZodError` issues. Use `safeParse` when you need\n  zod's error shape.\n- The classifier reads `schema._zod.def`, which is zod's internal tree. The\n  peer range is pinned to zod 4 and the differential suite is the tripwire for\n  internals moving.\n- Async refinements are not supported; `safeParse` is synchronous, as in zod.\n\n## Standard Schema\n\nThe compiled object implements Standard Schema V1, so anything that accepts a\nstandard schema runs the fast path without knowing either library:\n\n```js\nconst result = check['~standard'].validate(data)\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}