chore(deps): update dependency zod to v4 #7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "renovate/zod-4.x"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR contains the following updates:
^3.23.0→^4.0.0Release Notes
colinhacks/zod (zod)
v4.4.3Compare Source
Commits:
4c2fa95docs: use Zernio primary wordmark for gold sponsor logo2aeec83docs: prune lapsed gold sponsors and rebalance logo sizing7391be8docs: prune lapsed silver/bronze sponsors and add active ones2c70332docs: normalize bronze sponsor logos to github avatar pattern9195250docs: remove Mintlify from bronze sponsors (churned)b8dffe9docs: remove Numeric and Speakeasy (2+ missed monthly cycles)1cab693fix(v4): restore catch handling for absent object keys (#5937) (#5939)c2be4f8fix(v4): generalize optin/fallback to transform; restore preprocess on absent keys (#5941)f3c9ec04.4.31fb56a5docs: document release procedure in AGENTS.mdv4.4.2Compare Source
Commits:
0c62df0Clean up docs navigation and stale labels (#5901)20cc794chore: add security policy and refresh tooling deps6fbe07bfix(docs): heading anchor links now include the hash so it doesnt scoll all the way up, follows navbar logic (#5791)4bbed1bTighten discriminated union option typingbbac3e5Update PR guidance for agentscf0dc94Merge remote-tracking branch 'origin/main' into fix-discriminated-union-key-constraint292c894docs: add Zernio gold sponsor1fc9f31docs: document codec inversion1373c85docs: remove AI disclosure guidancee20d02bchore: ignore triage notese58ea4ddocs: test Zod Mini tab code heights905761adocs: document preprocess input type narrowingbf64bacchore: tighten test guidance in AGENTS.md8ec4e73chore: update play.ts scratch02c2bafMake z.preprocess defer optionality to inner schema (#5929)88015dffix(docs): drop deprecatedbaseUrlfrom tsconfigc59d4474.4.2v4.4.1Compare Source
Commits:
481f7beci: gate release publishing on full test workflow95ccab4test(v3): restore optional undefined expectationscede2c6fix(v4): reject tuple holes before required defaults (#5900)edd0bf0release: 4.4.1180d83ddocs: remove Jazz featured sponsorv4.4.0Compare Source
4.4.0
This is a minor release with a wide set of correctness and soundness fixes. Some fixes intentionally make Zod stricter, so code that depended on previously accepted invalid or ambiguous inputs may need small updates.
Potentially breaking bug fixes
Tuple defaults now materialize output values correctly
Fixed in #5661. Tuple parsing now more accurately reflects defaults, optional tails, explicit
undefined, and under-filled inputs. The headline behavior is that defaults in tuple positions now properly appear in parsed output.Trailing optional elements that are absent still stay absent; they are not filled with
undefined.But explicit
undefinedvalues supplied by the caller are preserved.When optional elements appear before later defaults, the parsed tuple is now dense so array operations behave predictably.
Tuple length errors are also more consistent now. Since
z.function()arguments are tuple-shaped, function input errors may look different.Required object properties with
z.undefined()Fixed in #5661, with follow-up coverage in
57d80a82. A property whose schema isz.undefined()is now treated as required. The key must be present, but its value may beundefined.Use
.optional()when the key itself may be absent.This also affects related
.catch(),.partial(),.default(), and.prefault()combinations that previously relied on missingz.undefined()keys being treated as optional.Safer
.merge()behavior with refinementsFixed in #5856. The
.merge()method now throws when the receiver has refinements, rather than silently producing ambiguous refinement behavior. Refinements from the second schema are preserved.JSON Schema
$defsentries no longer include redundantidFixed in #5759. JSON Schema conversion through
z.toJSONSchema()now strips redundantidfields from$defsentries. This is required for correctness in older JSON Schema dialects from before$idwas introduced: in those dialects,idchanges the resolution scope, so leaving it inside an extracted definition can make references resolve incorrectly. The removed value was redundant because the schema had already been extracted into$defs, so the definition key itself is the identifier. This may affect consumers that were reading those internalidfields directly.Other JSON Schema fixes in this release:
.describe(): #5797String validators are stricter
Base64 validation now rejects whitespace instead of allowing
atob()-style whitespace stripping. Fixed in #5888.Other string validator changes:
z.cuid()has been tightened, and CUID v1 is now deprecated. Fixed in #5880.z.httpUrl()now rejects malformed HTTP(S) URLs with a missing slash after the protocol. The underlyingURLconstructor normalizes inputs likehttps:/example.com, but Zod now rejects them instead of accepting the repaired URL. Fixed in #5672, related to #5284.Union paths are fixed in formatted errors
Two union-related error fixes landed:
z.treeifyError()andz.formatError(). Fixed in #5708 and60ff3987.ZodErroroutput.Other fixes
Record key transforms now run
Fixed in #5891. Record schemas now run transforms on record keys.
Related record fixes:
invalid_keyissues. Fixed in #5719.z.record(valueType)form works again. Fixed in0e960108.Metadata and input handling in
fromJSONSchema()Schema generation from JSON Schema now applies metadata more consistently across
enum,const,not,anyOf, and multi-type schemas. Fixed in #5758. It also rejects or normalizes more non-JSON-like inputs, including cyclic objects andBigInt. Fixed in87cf0f93.Codecs
Codec changes:
z.discriminatedUnion().encode()now works when the discriminator uses a codec. Fixed in #5769.Transform context
Transform callbacks now support
ctx.addIssue(). Fixed in #5699.Conditional
.superRefine()withwhenThe
whenoption was added for.superRefine(). Added in #5741, with related abort behavior fixed in #5681.Defaults for
MapandSetDefaults for
MapandSetare now cloned instead of shared across parses. Fixed in #5855.Empty unions
Empty
z.union([]),z.xor([]), and discriminated unions no longer crash at construction time. They construct and fail at parse time. Fixed in #5869.Floating-point multiples
Number
multipleOf()/step()validation is more accurate for decimal and exponent edge cases. Fixed in #5687 and #5793.Global config and
jitlessConfiguration fixes:
globalThis, improving behavior across mixed CJS/ESM module instances. Fixed in #5889.Prototype pollution hardening
Object catchall paths now skip
__proto__keys. Fixed in #5898.Performance improvements
Reduced memory usage from lazy-bound methods
Fixed in #5897. Classic builder methods are now lazy-bound through a shared internal prototype instead of eagerly attached per schema instance. This significantly reduces per-schema method allocation overhead, especially in codebases that construct many schemas. Detached methods continue to work:
Improved tree-shaking
Implemented in
195e8696and #5689. Top-level factory calls are annotated as pure, and generated stub package manifests now includesideEffects: false. This gives bundlers more room to remove unused Zod code.This is intended as the conclusive fix for a long-standing class of tree-shaking and bundle-size issues, especially in Next.js and Turbopack projects. The most visible symptom was that unused validators and locales could survive bundling even when importing from
zod/minior from a narrow subpath.Related reports include:
zod/minibundle-size reports: #5561, #5665, #4369, #4572Locales
Added or updated locale support:
Locale message text changed in some cases, which may affect snapshots.
Closed issues
The following issues were closed by PRs included in this release:
string.abort: truein.refine()checks withwhen.addIssueto transform context.deleteinfinalizeIssue.optionsto invalid discriminator errors.fromJSONSchema().idfrom$defsentries in JSON Schema output.z.custom()docs for v4 compatibility.discriminatedUnion().encode()with codec discriminators.multipleOf()validation.MapandSetdefaults..merge()refinement semantics with.extend().jitlessconfig in the eval probe.z.union([])andz.xor([]).z.record().Commits
44f6a03efix(locales): correct Georgian translation for 'string' to 'ველი' (#5655) by @tushargr0ver7b43bc64docs(ecosystem): add Hono Takibi (#5651) by @nakita628119376b9feat: add map support to Uzbek locale (#5599) by @uchkunr8fbf701etest: add edge case tests for boundary values (#5601) by @uchkunrf1f93c2bFix order of brand method examples in api.mdx (#5604) by @onurtemiz10105ee4docs: Fix typos in json-schema documentation (#5608) by @SaKaNa-Y2d367139feat: add hr translation (#5610) by @vuki65654902cb7chore: update pullfrog.yml workflow89ba70f2chore: add sideEffects false to stub package.json for tree-shaking (#5689) by @jesse-holdeneaa3c2c3Update positive checks to use alias.gt(0)in the docs (#5671) by @Fredkiss365f1f404fix typo (#5676) by @Nikita0x5b574501fix: respectabort: truein.refine()for checks withwhenfunction (#5681)539de140docs: fix README links for async refinements/transforms (#5682) by @pavan-sh46cd10e7docs: fix README anchor links for async APIs (#5683) by @pavan-sh55747b3cRemove deprecated downlevelIteration option (#5684) by @RyanCavanaugh3a818de1fix(v4): handle multi-digit exponents in floatSafeRemainder (#5687) by @shakecodeslikecray3cd45ebcfix(v4): add strict validation tohttpUrl()(#5672) by @LuckySilver00217d98c909add Sanity as silver sponsor and Mintlify as bronze sponsorc7805073move Sanity and Mintlify to top of sponsor listsbee2dc8ddocs: movez.iso.time()from format to pattern section (#5696)2f8414bcfix: add missing addIssue to transform context (#5699) by @F-A-N-D-Ed3c0ec87docs: add note about removed.errorsalias in v4 changelog (#5705) by @togami2864fa338a3bfix(v4): JSON schema min/max intersection for draft-04 and openapi-3.0 (#5700) by @ebroder3473b288chore: bump zshy to ^0.7.1cc8f9b7cdocs: improve README wording and fix typos (#5736) by @vedanshshettif5336717feat: add json-up to ecosystem (#5740) by @mrspence60ff3987fix(v4): preserve parent path when treeifying nested union/key/element issues08b14b51perf: avoiddeleteinfinalizeIssueto keep V8 fast mode (#5718)9cf868d2fix(v4): treeify error nested union bug (#5708) by @dstashevskyi28f39a6dAdd JSONType export (#5709) by @RobinVdBroeck65fab33efeat: allowwhenparameter in.superRefine()(#5741) by @vilvai7f87df1erefactor(v4): remove unnecessary type assertions (#5720) by @chisaki66518f15ddPreprocess is not deprecated (#5721) by @mxdvl2e5b23dcfix: add options to invalid discriminator errors (#5723) by @Danielchinasa7f789deffix: skip non-enumerable properties in record validation (#5719) by @veeceeyee15fa19docs: add AGENTS notes for JSDoc, PR comments, and PR worktree workflowf52b4d28Revert "docs: improve README wording and fix typos (#5736)"ddb41391test: increase timeout for redos checker in datetime.test.ts (#5744) by @rishadaufabc07e459docs: fix doc (#5745) by @xgaiae06af5deUpdate Hey API description (#5748) by @mrlubos28c156e2fix: apply description and default metadata to enum, const, and not schemas in fromJSONSchema (#5758) by @mibragimovf457edf1Fix grammar in CONTRIBUTING.md (#5765) by @siekmang411f6c64fix(v4): resolve stack overflow in toJSONSchema for recursive lazy with describe (#5797) by @Hassad67445dd421edocs: add tone guidelines for issue and PR comments to AGENTS.mdddd20a30test: align optional property assertions with actual inferred typesa1cf8a93docs: update z.custom example for v4 compatibility (#5763) by @andrewdameliob6a3b336fix: strip redundant id from$defsentries in toJSONSchema (#5759) by @mibragimovc7a8ccc0fix: discriminatedUnion encode() with codec discriminator (#5769) by @mahmoodhamdi87cf0f93fix(fromJSONSchema): normalize input via JSON round-trip7163e6f2feat: add.invert()method to ZodCodec (#5770) by @mahmoodhamdib59b9b13fix: replace.defaultwith.prefault(#5776) by @alanskovrlj93bba686docs: add Zod AOT to ecosystem page (#5806) by @wakita1810092564caa4fix(docs): add custom 404 page with proper theme support (#5779) by @WolfieLeader5b7ed214fix: correct multipleOf float validation using tolerance-based comparison (#5793) by @cyphercodescc9139d2docs: fix self-referencing schema in refine when() example (#5812) by @claygeo0e960108fix(v4): support v3-style single-arg z.record(valueType)41b25af9docs(agents): refine PR comment tone guidance4c03c20dUpdate Italian locale error messages for validation (#5852) by @pastorello37ac1ba0fix(fr): translate issue.origin in too_big/too_small errors (#5845) by @Ouaziz-chedli345be203docs: add validex to ecosystem (#5848) by @chiptoma3c1f32bdfeat(locales/en): handle instanceof and add comprehensive locale tests888e52bbfeat(locales): add Greek (el) locale (#5840) by @saileshbrobf6d99edRevert "feat(locales/en): handle instanceof and add comprehensive locale tests"e8196a8dfix(resolution): align expected fr message with translated localeb6b12882correct logic for validating length (#5843) by @nameearly34f60159fix(v4): clone Map and Set in shallowClone to prevent shared state across.default()parses (#5855) by @artur-seppa91a7d0d1fix(v4): reject whitespace in z.base64() to close atob bypass23edf484Revert "fix(v4): reject whitespace in z.base64() to close atob bypass"15cafa13fix(v4): throw on.merge()receiver with refinements; preserve refinements from second schema (#5856) by @solssak584b1089fix(v4): reject whitespace in z.base64() to close atob bypass (#5888) by @colinhacksb9b62c65fix(core): honourjitlessconfig inallowsEvalprobe (#5864) by @doksonfffe99bdfix(v4): construct empty unions instead of crashing (#5869) by @tjenkinson285bde7ffeat(core): shareglobalConfigacross module systems viaglobalThis(#5889) by @colinhacks195e8696perf(v4): mark top-level factory calls as/*@​__PURE__*/for tree-shaking61d7bedbfix(v4): apply key schema transforms in z.record() (#5891) by @colinhacks45acd2adci(release): switch to npm trusted publishing via OIDC (#5890) by @colinhacks476ae243Tighten cuid() regex and deprecate CUID v1 (#5880) by @colinhacks6217527edocs(agents): document push-to-main footgun and version-bump rule (#5883) by @colinhacks757f0b0ffix(v4): apply util.Writeable in strictObject/looseObject for shape display parity (#5882) by @colinhacksfa4a3740fix(v4): apply util.Writeable in mini object constructors and extend/safeExtend/partial/required (#5895) by @colinhacksebc8287cfix(v4): emit falsy prefault values in toJSONSchema (#5893) by @mixelburg8fcb71a5perf(v4): lazy-bind builder methods to shared internal prototype (#5897) by @colinhacks76e8f706fix(v4): skip__proto__key in object catchall (#5898) by @colinhacksf0b0608eecosystem:eslint-plugin-zod-xiseslint-plugin-zodnow (#5637) by @marcalexiei0b5c3bc2docs: fix refinements examples in api.mdx (#5649) by @playoffthecuff327e152edocs(agents): refine PR comment tone guidance further57d80a82test(v4): pin object/tuple key optionality through optout propagationf19860f1fix: preserve context immutability in parse functions (#5632) by @bgk614ec979ad7feat: add Romanian (ro) locale (#5657) by @tushargr0verb6066b3efix(v4): align object and tuple optionality handling (#5661) by @Cyjin-janiad0b8271ci: update release workflow for trusted publishing6db607befix(release): keep JSR manifest publishablef778e02abuild: bump zshy for JSR wildcard exportsv4.3.6Compare Source
Commits:
9977fb0Add brand.dev to sponsorsf4b7baeUpdate pullfrog.yml (#5634)251d716Clean up workflow_calledd4132fix: add missing User-agent to robots.txt and allow all (#5646)85db85efix: typo in codec.test.ts file (#5628)cbf77bbAvoid non null assertion (#5638)dfbbf1cAvoid re-exported star modules (#5656)762e911Generalize numeric key handlingca3c862v4.3.6v4.3.5Compare Source
Commits:
21afffd[Docs] Update migration guide docs for deprecation of message (#5595)e36743eImprove mini treeshaking0cdc0b84.3.5v4.3.4Compare Source
Commits:
1a8bea3Add integration testse01cd02Support patternProperties for looserecord (#5592)089e5fbImprove looseRecord docsdecef9cFix lint9443aabDrop iso time in fromJSONSchema66bda74Remove .refine() from ZodMiniTypeb4ab94c4.3.4v4.3.3Compare Source
Commits:
f3b2151v4.3.3v4.3.2Compare Source
Commits:
bf96635Loosen strictObjectinside intersection (#5587)f71dc01Remove Juno (#5590)0f41e5a4.3.2v4.3.1Compare Source
Commits:
0fe8840allow non-overwriting extends with refinements. 4.3.1v4.3.0Compare Source
This is Zod's biggest release since 4.0. It addresses several of Zod's longest-standing feature requests.
z.fromJSONSchema()Convert JSON Schema to Zod (#5534, #5586)
You can now convert JSON Schema definitions directly into Zod schemas. This function supports JSON Schema
"draft-2020-12","draft-7","draft-4", and OpenAPI 3.0.The API should be considered experimental. There are no guarantees of 1:1 "round-trip soundness":
MySchema>z.toJSONSchema()>z.fromJSONSchema(). There are several features of Zod that don't exist in JSON Schema and vice versa, which makes this virtually impossible.Features supported:
string,number,integer,boolean,null,object,array)email,uri,uuid,date-time,date,time,ipv4,ipv6, and more)anyOf,oneOf,allOf)additionalProperties,patternProperties,propertyNames)prefixItems,items,minItems,maxItems)$reffor local references and circular schemasz.xor()— exclusive union (#5534)A new exclusive union type that requires exactly one option to match. Unlike
z.union()which passes if any option matches,z.xor()fails if zero or more than one option matches.When converted to JSON Schema,
z.xor()producesoneOfinstead ofanyOf.z.looseRecord()— partial record validation (#5534)A new record variant that only validates keys matching the key schema, passing through non-matching keys unchanged. This is used to represent
patternPropertiesin JSON Schema..exactOptional()— strict optional properties (#5589)A new wrapper that makes a property key-optional (can be omitted) but does not accept
undefinedas an explicit value.This makes it possible to accurately represent the full spectrum of optionality expressible using
exactOptionalPropertyTypes..apply()A utility method for applying arbitrary transformations to a schema, enabling cleaner schema composition. (#5463)
.brand()cardinalityThe
.brand()method now accepts a second argument to control whether the brand applies to input, output, or both. Closes #4764, #4836.Type predicates on
.refine()(#5575)The
.refine()method now supports type predicates to narrow the output type:ZodMapmethods:min,max,nonempty,size(#5316)ZodMapnow has parity withZodSetandZodArray:.with()alias for.check()(359c0db)A new
.with()method has been added as a more readable alias for.check(). Over time, more APIs have been added that don't qualify as "checks". The new method provides a readable alternative that doesn't muddy semantics.z.slugify()transformTransform strings into URL-friendly slugs. Works great with
.with():z.meta()andz.describe()in Zod Mini (947b4eb)Zod Mini now exports
z.meta()andz.describe()as top-level functions for adding metadata to schemas:More ergonomic intersections #5587
When intersecting schemas that include
z.strictObject(), Zod 4 now only rejects keys that are unrecognized by both sides of the intersection. Previously, any unrecognized key from either side would cause an error.This means keys that are recognized by at least one side of the intersection will now pass validation:
When both sides are strict, only keys unrecognized by both sides will error:
New locales
am) (#5531)uz) (#5519)Bug fixes
All of these changes fix soundness issues in Zod. As with any bug fix there's some chance of breakage if you were intentionally or unintentionally relying on this unsound behavior.
⚠️
.pick()and.omit()disallowed on object schemas containing refinements (#5317)Using
.pick()or.omit()on object schemas with refinements now throws an error. Previously, this would silently drop the refinements, leading to unexpected behavior.Migration: The easiest way to migrate is to create a new schema using the
shapeof the old one.⚠️ overwriting properties with
.extend()disallowed on object schemas with refinements (#5317)Similarly,
.extend()will throws on schemas with refinements if you are overwriting existing properties.Instead you can use
.safeExtend(), which statically ensures that you aren't changing the type signature of any pre-existing properties.⚠️ Stricter object masking methods (#5581)
Object masking methods (
.pick(),.omit()) now validate that the keys provided actually exist in the schema:Additional changes
z.iso.timewith minute precision (#5557)includesmethod params typing to acceptstring | $ZodCheckIncludesParams(#5556)implementAsyncinferred type to always be a promise (#5476)Dateinstances to numbers inminimum/maximumchecks (#5351)z.record()(#5585)~standardschema property (#5363)@__NO_SIDE_EFFECTS__for better tree-shaking (#5475)v4.2.1Compare Source
Commits:
5b5b1294.2.1v4.2.0Compare Source
Features
Implement Standard JSON Schema
standard-schema/standard-schema#134
Implement
z.fromJSONSchema()Implement
z.xor()Implement
z.looseRecord()Commits:
af49c08Update docs for JSON Schema conversion ofz.undefined()(#5504)767f320Add.toJSONSchema()method (#5477)e17dcb6Addz.fromJSONSchema(),z.looseRecord(),z.xor()(#5534)v4.1.13Compare Source
Commits:
5c2602cUpdate AI widget (#5318)d3da530reflect the specified regex correctly in error (#5338)39f8c45faster initialization (#5352)e9e2790Clean up comment8e4739fUpdate inferred z.promise() type2849df8fix(locales): improve Dutch (nl) localization (#5367)b0d3c9fRun tests on windows6fd61b7feat unitest (#5358)a4e4bc8Lock to node 248de8badFix windows buildb2c186bUse Node LTSb73b1f6Consolidate isTransforming logicd85f3eaFix #53531bac0f3Fix test.yml86d4dadFix partial record5e6c0fdFix attw on windows27fc616Extend test timeout8d336c4Remove windows runner5be72e0chore(doc): update metadata.tsx (#5331)cb0272adocs: add 'cd zod' step to development setup instructions (#5394)24e3325docs: replace 'Refinement' with 'Transform' in transforms section (#5397)644a082chore: add resource for validating environment variables with Zod (#5403)5e1cfcfChange doc for email validation method in Zod schema (#5392)88cf944Fix: Iterate over keys in catchall object using "in" operator. (#5376)aa43732Emphasise thatenumvalidates against values, for object literal &enums (#5386)3a4bd00Improve Hebrew localization for Zod error messages (#5409)c10f9d1Fix typos (#5420)86f0ef9Documentation Improvements (#5417)e120a48Fix opt tuplef9bbb50Improve tuple0ba0f34Optimize docs caching/ISR (#5433)c3ec66cImprove docs cachingc8cce4bdocs: fix typos and links (#5428)84ec047docs(ecosystem): Add react-f3 (#5429)3396515Docs: Fix typo in safeExtend description (#5445)3d93a7dfeat: MAC address validation in v4 and mini (#5440)f2f0d17Fix dual package hazard forglobalRegistry(#5452)9fc493ffix: use oneOf for discriminated unions in JSON Schema (#5453)603dbe8Clean up regex, drop backreferencesab69b9eUpdate mac addr testsf791052chore: upgrade vitest to v4 (#5028)f97e80dfix(core): prevent infinite recursion for recursive tuples (#5089) (#5094)002e01afix(record): handle non-function constructor field in isPlainObject (#5098)6716517docs(contributing): add instructions on building @zod/docs (#5114)8b0603dFix typo in ISO time documentation (#5277)be85eccdocs(codecs): correctstringToDatesafeDecode methods (#5302)50bba54Add zodgres to ecosystem documentation (#5308)377f5d1Addzod-to-mongo-schemato ecosystem documentation (#5457)dea32d5docs(ecosystem): add fn sphere and zod-compare (#5326)02ea4c8Add Claude Code GitHub Workflow (#5460)d44253dAdd support for number literal and TypeScript's enum keys inz.record(#5334)f52344eFix vitest 40f4ce73Do not allow unsound pick/omit162fe29Add z.meta and z.describe3de39eeImplement slugify5bfc8f2Fix docs0e803a2Revert "Do not allow unsound pick/omit"a774750v4.1.132cdd82b4.1.134063e80Update check-semver scriptv4.1.12Compare Source
Commits:
0b109c3docs(ecosystem): add bupkis to the ecosystem section (#5237)d22ec0ddocs(ecosystem): add upfetch (#5238)c56a4f6docs(ecosystem): addeslint-plugin-zod-x(#5261)a0abcc0docs(metadata.mdx): fix a mistake in an example output (#5248)62bf4e4fix(ZodError): prevent flatten() from crashing on 'toString' key (#5266)02a5840refac(errors): Unify code structure and improve types (#5278)4b1922adocs(content/v4/index): fix zod version (#5289)3fcb20fAdd frrm to ecosystem (#5292)fda4c7cMake docs work without tokenaf44738Fix lint77c3c9fExport bg.ts3b94610v4.1.12v4.1.11Compare Source
Commits:
2bed4b34.1.11v4.1.10Compare Source
Commits:
7ffedd0Fix shape caching (#5263)82cd717v4.1.10v4.1.9Compare Source
Commits:
a78716dUpdate zshy (#5249)923af80Publish zod@4.1.9v4.1.8Compare Source
Commits:
36c4ee3Switch back to weakmapa1726d54.1.8v4.1.7Compare Source
Commits:
0cca351Fix variable name inconsistency in coercion documentation (#5188)aa78c27Add copy/edit buttons76452d4Update button txt937f73cFix tsconfig issue in bench976b436v4.1.6 (#5222)4309c61Fix cidrv6 validation - cidrv6 should reject invalid strings with multiple slashes (#5196)ef95a73feat(locales): Add Lithuanian (lt) locale (#5210)3803f3fdocs: update wrong contents in codeblocks inapi.mdx(#5209)8a47d5cdocs: update coerce example inapi.mdx(#5207)e87db13feat(locales): Add Georgian (ka) locale (#5203)c54b123docs: adds@traversable/zodand@traversable/zod-testto v4 ecosystem (#5194)c27a294Fix two tiny grammatical errors in the docs. (#5193)23a2d66docs: fix broken links in async refinements and transforms references (#5190)845a230fix(locales): Add type name translations to Spanish locale (#5187)27f13d6Improve regex precision and eliminate duplicates in regexes.ts (#5181)a8a52b3fix(v4): fix Khmer and Ukrainian locales (#5177)887e37cUpdate slugse1f1948fix(v4): ensure array defaults are shallow-cloned (#5173)9f65038docs(ecosystem): add DRZL; fix Prisma Zod Generator placement (#5215)aa6f0f0More fixes (#5223)aab33564.1.7v4.1.6Compare Source
v4.1.5Compare Source
Commits:
530415fUpdate docsb7b081dUpdate z.function() type to support array input (#5170)780cf574.1.5v4.1.4Compare Source
Commits:
3291c61fix(v4): toJSONSchema - wrong tuple withnulloutput when targetingopenapi-3.0(#5156)23f41c7test(v4): toJSONSchema - usevalidateOpenAPI30Schemain all relevant scenarios (#5163)0a09fd2Update installation instructions4ea5fec4.1.4v4.1.3Compare Source
Commits:
98ff675Drop stringToBooleana410616Fix typo0cf4589fix(v4): toJSONSchema - add missing oneOf inside items in tuple conversion (#5146)8bf0c16fix(v4): toJSONSchema tuple path handling for draft-7 with metadata IDs (#5152)5c5fa90fix(v4): toJSONSchema - wrong record output when targetingopenapi-3.0(#5141)87b97ccdocs(codecs): update example to use payloadSchema (#5150)309f358fix(v4): toJSONSchema - output numbers with exclusive range correctly when targetingopenapi-3.0(#5139)1e71ca9docs: fix refine fn to encode works properly (#5148)a85ec3cfix(docs): correct example to useLooseDoginstead ofDog(#5136)3e982744.1.3v4.1.2Compare Source
Commits:
e45e61bImprove codec docs25a4c37fix(v4): toJSONSchema - wrong record tuple output when targetingopenapi-3.0(#5145)0fa4f46Use method form in codecs.mdx940383dUpdate JSON codec and docs3009fa84.1.2v4.1.1Compare Source
Commits:
648eb43Remove codecs from sidebare7e39a99Improve codec docse5085beAdd images028b289Add methods10cc9944.1.1v4.1.0Compare Source
The first minor version since the introduction of Zod 4 back in May. This version contains a number of features that barely missed the cut for the 4.0 release. With Zod 4 stable and widely adopted, there's more time to resume feature development.
Codecs
This is the flagship feature of this release. Codecs are a new API & schema type that encapsulates a bi-directional transformation. It's a huge missing piece in Zod that's finally filled, and it unlocks some totally new ways to use Zod.
New top-level functions are added for processing inputs in the forward direction ("decoding") and backward direction ("encoding").
.parse()vs.decode()Both
.parse()anddecode()process data in the "forward" direction. They behave identically at runtime.There is an important difference however. While
.parse()accepts any input,.decode()expects a strongly typed input. That is, it expects an input of typestring, whereas.parse()acceptsunknown.Encoding
You can use any Zod schema with
.encode(). The vast majority of Zod schemas are non-transforming (the input and output types are identical) so.decode()and.encode()behave identically. Only certain schema types change their behavior:B->Aand executes theencodetransform during encodingB->Ainstead ofA->BThe usual async and safe variants exist as well:
Example codecs
Below are some "worked examples" for some commonly-needed codecs. These examples are all tested internally for correctness. Just copy/paste them into your project as needed. There is a more comprehensive set available at zod.dev/codecs.
stringToBigIntConverts
bigintinto a serializable form.jsonParses/stringifies JSON data.
To further validate the data,
.pipe()the result of this codec into another schema.Further reading
For more examples and a technical breakdown of how encoding works, reads theannouncement blog post and new Codecs docs page. The docs page contains implementations for several other commonly-needed codecs:
stringToNumberstringToIntstringToBigIntnumberToBigIntisoDatetimeToDateepochSecondsToDateepochMillisToDatejsonCodecutf8ToBytesbytesToUtf8base64ToBytesbase64urlToByteshexToBytesstringToURLstringToHttpURLuriComponentstringToBoolean.safeExtend()The existing way to add additional fields to an object is to use
.extend().Unfortunately this is a bit of a misnomer, as it allows you to overwrite existing fields. This means the result of
.extend()may not literallyextendthe original type (in the TypeScript sense).To enforce true
extendslogic, Zod 4.1 introduces a new.safeExtend()method. This statically enforces that the newly added properties conform to the existing ones.Importantly, this new API allows you to safely extend objects containing refinements.
Previously (in Zod 4.x) any refinements attached to the base schema were dropped in the extended result. This was too unexpected. It now throws an error. (Zod 3 did not support extension of refined objects either.)
z.hash()A new top-level string format for validating hashes produced using various common algorithms & encodings.
The following hash algorithms and encodings are supported. Each cell provides information about the expected number of characters/padding.
"hex""base64""base64url""md5""sha1""sha256""sha384""sha512"z.hex()To validate hexadecimal strings of any length.
Additional changes
FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF) per the RFC$ZodFunctionis now a subtype of$ZodTypeCommits
edd4fea- Closes #51275d4a315- Closes #5116f3f0955- Closes #51080114d5b- #51223b077c3- #51211e06af8- #5113b01b6f3— #5052571ab0c— #5051d3ea111— #5049b8e3f87— #4865v4.0.17Compare Source
Commits:
1cebf33Add blog (#5074)fc1e556Fixes #5073cc63f95v4.0.17v4.0.16Compare Source
Commits:
d589186fix: ensure keyof returns enum (#5045)4975f3afeat: add discriminator generic (#5044)0a463e3Update speakeasy files12658afFix Edit page buttons47e6604fix:edit this pagebutton, now redirects to correct url using the new path (#5056)7207a2dUpdate Hey API link to Zod v3 plugin (#5060)6887ff3Update Hey API link to Zod plugin (#5059)ffff1aaClone POJO objects during defaulting/prefaultinga227cb3v4.0.16v4.0.15Compare Source
Commits:
7e7e346Clean up docsf2949a8[docs] Fix migration guide upgrade command (#5021)d43cf19Fix recursive object initialization errors with check() and other methods (#5018)3de2b63fix: remove redundant Required<> from input and output type definitions (#5033)93553bdAdd needs info03cfa8d4.0.15v4.0.14Compare Source
Commits:
99391a8Docs: Fix typo (#5005)e25303eDocs: fix typo (#5008)dbb05efAdd JSON Schema draft-04 output (#4811)b8257d7Improve tuple recursive inference.9bdbc2fAvoid infinite loops in defineLazy. Fixes #4994.af96ad44.0.14v4.0.13Compare Source
Commits:
362eb33Fix optional + pipe handling. Closes #5002. v4.0.13v4.0.12Compare Source
Commits:
ff83fc9Add eslint-plugin-import-zod (#4848)7c9ce38Update docs for z.property check (#4863)c432577docs: add jwt schema docs (#4867)35e6a6fAdd llms.txt (#4915)3ac7bf0Clean up Edit this Page60a9372Implementllms-full.txt(#5004)73a19704.0.12v4.0.11Compare Source
Commits:
8e6a5f8Fix “Edit on Github” link (#4997)930a2f6Fix number of errors in doc (#4993)c762dbbfeat(locale): Add Yoruba (yo) locale (#4996)9a34a3aZod 4.0.11 (#4981)v4.0.10Compare Source
Commits:
291c1caAdd should-build scripte32d99bMove should-build scriptd4faf71Add v3 docs (#4972)dfae371Update Jazz img on v3 docsd6cd30dfix #4973 (#4974)1850496Fix typo invalype(#4960)4ec2f87Add Zod Playground to zod 4 ecosystem (#4975)2b571a2Update docs z.enum with object literal example (#4967)813451dv4.0.10 (#4978)v4.0.9Compare Source
Commits:
4e7a3efv4.0.9 (#4970)v4.0.8Compare Source
Commits:
3048d14Fix #4961v4.0.7Compare Source
Commits:
7ab1b3cDo not continue parsing in ZodPipe if issues exists. Closes #4926.34b400a4.0.7v4.0.6Compare Source
Commits:
a3e4391Unwiden catch input type (#4870)499df78Add RFC 9562 mentions. Closes #4872d0493f3Doc tweak - spread vs destructuring (#4919)8dad394feat: Icelandic translation (#4920)2ffdae1Bulgarian (bg) translation (#4928)0973135docs: add valype to xToZodConverts (#4930)d257340Remove moduleResolution callout (#4932)075970ddocs: add coercion note to fix compile errors (#4940)b9e8a60Add@hey-api/openapi-tsto Zod 3 ecosystem (#4949)ad7b0ffAdd@hey-api/openapi-tsto Zod 3 ecosystem (#4942)4619109feat(locales): add Danish translations (#4953)cb84a57Point to zod-v3-to-v4 codemod in Zod 4 migration guide (#4954)28a5091Update api.mdx (#4955)7f3cf94Fix URL sup example (#4959)17e7f3bAdd@hey-api/openapi-tsto Zod 4 ecosystem (#4950)f75d852fix: escapes decimal place inz.literal(#4895)7dd7484v4.0.6 (#4941)v4.0.5Compare Source
Commits:
f91a73eSupport pipes in discriminated unions. Closes #4856 (#4861)45afab04.0.5v4.0.4Compare Source
Commits:
9335f05AddsZodFirstPartyTypeKindstub to fix module resolution failure insidezod-to-json-schemav4.0.3Compare Source
Commits:
5905a8dImprove check-versions scriptf3e749bRemove global File interface44a936c4.0.274006edFix JSR provenanceff4af5e4.0.3ce573e8Update test badge9a7161aFix versionsv4.0.2Compare Source
v4.0.1: v4.0.0Compare Source
With this release,
zod@4.0.0has been published tonpm. There were no code changes between 3.25.76 and 4.0.0!Zod 4 has been stable for the past 6 weeks, but it was published inside zod@3.25.x on npm. this transitionary window gave the ecosystem time to incrementally support for Zod 4 (without dropping support for Zod 3). As there is now near-universal support for Zod 4 in the ecosystem, ths time feels right to finally put a bow on things 🎀
To upgrade to Zod 4:
If you’ve already migrated to Zod 4 using the subpaths, there are no changes required. however you can optionally simplify your imports (recommended)
Library authors — if you've already implemented Zod 4 support according to the best practices outlined in the Library authors guide, bump your peer dependency to include
zod@^4.0.0:There should be no other code changes necessary. No code changes were made between the latest
3.25.xrelease and4.0.0. This does not require a major version bump.v4.0.0Compare Source
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate.
/oc check if the potentially breaking changes in this dependecy affect this app
No breaking changes affect this app.
Zod v4 is declared as a dependency in
mcp-wrapper/package.jsonbut is not imported or used anywhere in the codebase. All 7 TypeScript source files and the test file were checked — none referencezod,zod/mini, or any Zod features.Zod is an orphaned/leftover dependency. The upgrade has zero impact on this app.
opencode session | forgejo run