Update dependency zod to v4.6.5 #139
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MobiusReactor/TicTacToeV2!139
Loading…
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:
4.4.3→4.6.5Release Notes
colinhacks/zod (zod)
v4.6.5Compare Source
Commits:
d2b135cdocs: add the 4.6.x patch highlights to the 4.6 postf1448f7docs: fold the 4.6.x patch highlights into the 4.6 post's own sectionsde65a5cdocs: lead the properties section with the check and add a Zod Mini tab (#6598)56222cdfeat(instanceof): key the .properties() shape off the instance type (#6600)ca0229aRevert "feat: add z.currencyCode() over a vendored ISO 4217 list, refreshed weekly by CI (#6595)"cc4cd4eRevert "Revert "feat: add z.currencyCode() over a vendored ISO 4217 list, refreshed weekly by CI (#6595)""0f3f5ee4.6.559bbc03chore: re-pin the integration peers to the workspace zod after the 4.6.5 bumpv4.6.4Compare Source
A patch on top of 4.6.3.
d6bc1e30feat: addz.currencyCode()over a vendored ISO 4217 list, refreshed weekly by CI (#6595)ad32d751perf:z.url()rejects an invalid URL withURL.canParse()instead of a throwing constructor, about 50x faster; fewer allocations on the validation path (#6588)2bb08717chore: re-pin the integration peers to the workspace zod after the 4.6.4 bumpf6e1701achore(deps): bump next to 15.5.25 and vite to 7.3.6 (#6153)v4.6.3Compare Source
A patch on top of 4.6.2.
413cce9afix(v4): make z.properties() a check again (#6594) — removes the standalonez.properties()schema from 4.6.0;z.instanceof().properties()and.check(...z.properties())are unchanged75d63ee1docs: show only the.properties()method form in the 4.6 post46da9572docs: match the error-message examples to what the parsers emitv4.6.2Compare Source
A patch on top of 4.6.1.
9446b5ccfix: preserve undefined prefault outputs and object keys (#6587) — closes #65850c483c58docs: the Zod 4.6 announcement post (#6546)a00c3f34docs: use Trigger.dev's brand-kit lockups for the platinum cardv4.6.1Compare Source
A patch on top of 4.6.0.
b12aa523fix: preserve unique tags with defaulted discriminators (#6582) — closes #6577dd9c36fafix(v4): defer recursive object index inference (#6580)3b154992feat(lang): add Tajik (tg) locale (#6581) by @ismoil772efa8b80ci: give the npm wait a real budget and drop the back-publish path (#6583)v4.6.0Compare Source
Zod 4.6 is now available.
At a glance:
.validate()— checks input validity without building a result (up to 35x faster than.safeParse().successon a compiled schema)z.instanceof().properties()— validates properties of an instancefromJSONSchema()— enforces six validation keywords it used to ignorez.iban()— electronic-format IBAN plus mod-97 checksumz.withParser()— installs a parser generated elsewhere, for environments withoutnew Functionz.validate()underrequire)@zod/mini— Zod Mini as a standalone package, versioned in lockstep withzodsince 4.5.validate()Standalone boolean validation, in Zod, Zod Mini, and Zod Core. It answers "is this input valid?" without constructing a
ZodError, which makes rejection cheap. The return type is a guard on the schema's input type.It is a method on Zod Classic schemas too. (#6547)
In conjunction with
z.compile(), this can be up to 35x faster than.safeParse().successon invalid input.Time per call on invalid input, compiled with z.compile() — lower is better (benchmark)
Uncompiled schemas
Without compilation it is up to 5.9x faster. The saving is the result object:
.safeParse()allocates one with an accessor pair on every call, and.validate()allocates nothing.Time per call on invalid input, plain schemas — lower is better (benchmark)
Both charts measure the failure path. The key feature of
.validate()is that it can short-circuit on the first issue it encounters, instead of aggregating a fullZodIssue[]array.z.properties()A new API for validating specific properties of an object. Unlike
z.object()it validates in-place, so it plays nice with class instances. (#6536)A corresponding
.properties()method has been added toZodInstanceOf.Zod
Zod Mini
The input comes back untouched, so the prototype survives and the methods still work. That is the part
z.object()cannot do: it would hand back a plain object and theResponsewould be gone.fromJSONSchema()Six additional JSON Schema keywords are now supported in
z.fromJSONSchema(). (#6535)minProperties/maxPropertiesuniqueItemscontainsminContains/maxContainsBoth property bounds count the input's own keys. Array uniqueness is structural, so
[{ a: 1 }, { a: 1 }]is a duplicate.z.iban()A new string format: an IBAN in electronic format, with a valid ISO 7064 MOD 97-10 checksum. (#6571)
z.withParser()z.compile()builds its parser withnew Function, which a strict Content Security Policy blocks.z.withParser()is that installer on its own: it takes a parser generated somewhere else, at build time or by a native compiler, and installs it under the same contract. (#6575)The supplied parser owns the whole result, so it has to return what the schema would have returned. This one rebuilds the object rather than handing back its input, because
z.object()strips unknown keys. Returningz.INVALIDhands the input to the runtime, which stays the only source ofZodErrors.Faster CommonJS
TypeScript compiles a re-export to a getter, and 252 of the 255 exports on Zod 4.5's CommonJS entrypoint were getters. V8 could not see a constant callee behind one, so it could not inline the call. The 4.6 build emits plain properties and freezes the exports object. On a compiled schema,
z.validate()underrequireis about 3x faster than it was in Zod 4.5. (#6564)Only calls through the namespace were affected. A method call like
Player.safeParse(data)never reads the exports object, and the ESM build is unchanged.Memory retention in recursive schemas
A recursive schema held the input and output of its last parse until the next parse replaced it, so one long-lived schema pinned every object it had touched. Zod 4.4 released that input and Zod 4.5 did not, which surfaced as an out-of-memory failure on a repository-wide lint run. The parse state is weak throughout now: one parse of a 29k-node tree retains 2.2 MB where it used to retain 10.1 MB, and recursive parses give up about 6% for it. (#6572)
Bug fixes
⚠️ Error maps run on the first read of
errorBecause
safeParse()now builds its error lazily, error maps — global, locale, and per-schemaerror— run whenresult.erroris first read, not at parse time. Code that swapsz.config()between the parse and the read gets the newer configuration. (#6519)An error map with a side effect never runs if nothing reads the error. Throwing parses are unaffected —
.parse()builds and throws its error immediately, never takes the lazy path, and its stack still points at your call site.⚠️
z.emoji()rejects component-only stringsUnicode's
Emoji_Componentproperty covers the pieces that attach to an emoji, soz.emoji()accepted"123","#","*", and a lone zero-width joiner, variation selector, or skin tone modifier. The pattern now requires at least one pictograph, regional indicator, or keycap. (#6532)Flags, subdivision flags, skin-tone-modified emoji, and ZWJ sequences are unchanged. Closes #6515.
⚠️ Numeric enum options no longer include the reverse mappings
A numeric TypeScript enum also carries its reverse mapping (
0to"UK") at runtime. The parser already ignored those keys, but.optionswas read straight off the enum object, so a three-member enum listed six values and three of them failed to parse. (#6542)⚠️ base64 patterns
The runtime patterns for
z.base64()andz.base64url()are the character sets, with length and padding enforced in code, so a multi-megabyte string can no longer overflow the regex stack through a composed schema. The JSON Schema output still emits the exact block forms, soz.toJSONSchema()is unchanged. (#6534, #6527)Composing
z.base64()into a template literal now checks the alphabet but not the length, which is howz.creditCard()already behaves there. The exportedz.regexes.base64urlis now the length-aware form, so it overflows on a multi-megabyte input the same wayz.regexes.base64does.⚠️ The email pattern dropped its lookaheads
z.email()opened with two lookaheads, and the second scanned the whole string before the match began. Both are gone, and the rule they enforced — no empty segment in the local part — is expressed structurally instead, soz.email()accepts and rejects exactly what it did before. Valid addresses validate roughly twice as fast. (#6573)The pattern string is user-visible, and every copy of it changes:
z.regexes.email, which has no capture groups now — neither of the two it used to expose held a usable value;issue.patternon a failedz.email(); and thepatternthatz.toJSONSchema()emits, which no longer carries a lookahead, so validators outside ECMAScript can compile it.Composing an email into a template literal also stops applying its no-consecutive-dots rule to the rest of the string.
⚠️ Chained checks no longer overwrite each other in JSON Schema
Each check used to write its own bounds into the schema as it attached, in chain order, so a format check applied after
.min()and.max()replaced the tighter values with its own range. The converter folds the checks as a conjunction now. The order they are chained in no longer changes the output. (#6554, #6553)Runtime parsing enforced the bounds in every version. Only the emitted schema was wrong. The same fold fixes two more cases: a repeated
multipleOfkept the first divisor and dropped the rest, soz.number().multipleOf(2).multipleOf(3)emitted a schema that accepts 4, andz.string().min(8).length(5)emittedminLength: 5, widening a bound the runtime still rejected. Closes #6550.⚠️ Metadata members materialize on first read
Eight members on a Zod Classic schema —
.format,.minLength,.maxLength,.minValue,.maxValue,.isInt,.minDateand.maxDate— are computed from the checks now instead of being written onto every instance at construction. Each one is a prototype getter that becomes an own property on first read. (#6554)A key is absent until something reads it, and
Object.assign({}, schema)copies only the members that have been read. Deleting one restores the getter, and the next read recomputes it.The values can move too, because the getters read the same fold the JSON Schema converter does. An order-dependent chain reports the tighter bound now instead of whichever check wrote last.
Commits
Zod 4.6 rolls up 72 commits.
661673aedocs: make the 9thCO logo visible on the light theme by @colinhacks6de10dcedocs: reconcile the sponsor listings against every active sponsorship (#6579) by @colinhacks213ee75dfeat(compile): add z.withParser for externally generated parsers (#6575) by @colinhacksf9465d4edocs: reconcile the sponsor listings with active sponsorships (#6576) by @colinhacksf7fd5548perf(v4): drop the lookaheads from the email regex (#6573) by @colinhacks36f17960fix(v4): stop the memoizer from pinning a finished parse (#6572) by @colinhacks22bed613feat(v4): add z.iban() string format with mod-97 checksum (#6571) by @colinhacksc5b9bcb3bench: measure what a runtime island's leaked indent cost the generated source by @colinhackse54716cbdocs(ecosystem): add @apical-ts/craft (#5946) by @gunzipdcbcf052fix(compile): unwind the doc indent when a child generator throws (#6570) by @colinhacks277613a6docs: move the release procedure to the maintainer-local notes by @colinhackseb1c1089ci: release only on workflow_dispatch behind the npm environment (#6569) by @colinhacks741981ffperf(compile): for-in record walk, cheaper issue finalization, and a generative compile differential (#6567) by @colinhacks804e0f52perf: seal the CommonJS exports so require("zod") stops reading through a getter (#6564) by @colinhacks6f048367fix(v4): derive JSON Schema constraints by folding checks in the converter (#6554) by @colinhackse4d67f3eMigrate development and CI to Nub (#6562) by @colinhacks7a002366fix(v4): don't let format checks overwrite tighter min/max bounds (#6553) by @colinhacks5489a532test(v4): pin the check-chain case that keeps compiled validate's definite guard (#6551) by @colinhackse7604717docs: attribute the compiled failure cost to the fallback, not the double pass by @colinhacks764ac59fperf(v4): settle z.validate on the first failure in parse order (#6544) by @colinhacks07917f4ctest(v4): pin the lazy safeParse error's stack behavior (#6548) by @colinhacks62e6624bfeat(v4): add .validate() and .validateAsync() to Zod Classic (#6547) by @colinhackscafbee47fix(v4): parse recursive schemas built by a factory (#6530) by @colinhacks4d730882Release the parsed input once a failing safeParse builds its error (#6543) by @colinhacks90269c60Keep a numeric TS enum's reverse-mapping keys out of.options(#6542) by @colinhacks18e71c71Rename the JSON Schemaprocesshelper so bundler polyfills cannot collide (#6541) by @colinhacks68aca3dcdocs: cover the 4.5 API surface that never made it into the reference by @colinhackseca96871fix(v4): enforce the six JSON Schema keywords fromJSONSchema silently dropped (#6535) by @colinhacks81ded991perf: answer z.validate from the compiled fast path on invalid input (#6538) by @colinhacks51caf010refactor: collapse cachedInternal back into cached (#6540) by @colinhacksabfb3897feat(v4): make z.properties() a schema, and give z.instanceof() a .properties() method (#6536) by @colinhacks69f2a7ffCollapse toZod's normalizer and move its docs to the API reference (#6539) by @colinhacksbf990216perf: move util.cached's accessor to a prototype (#6537) by @colinhacksbec73beaperf(v4): build the safeParse error on first read (#6519) by @colinhacks07c43e2aKeep the runtime base64 regexes linear so composed parse paths cannot overflow (#6534) by @colinhacksbc1157e7docs: use a Response example for z.properties() by @colinhacks2ec972ecrefactor: collapse toZod's enum leaf normalizer to a dummy union (#6533) by @colinhacks68a609acWiden literal inputs in property check types (#6520) by @colinhacks0227e53ddocs: bump the star pill's GitHub mark to 20px by @colinhacks84dd3b0fperf: build literal and enum pattern regexes lazily (#6531) by @colinhacksf83ab511fix(v4): reject component-only strings from z.emoji() (#6532) by @colinhacks74f9a6d3docs: drop the toZod enum block from basics and pin the page's curation rule in a comment by @colinhacksa2a019a5Accept enum-typed targets in z.toZod (#6528) by @colinhacks319f47f4Emit a length-aware base64url pattern in toJSONSchema (#6527) by @colinhacks08ba069eperf(v4): read Luhn digits with charCodeAt instead of string indexing (#6529) by @colinhacks1ec6b7c5docs: add an RSS feed to the blog at /blog/rss.xml by @colinhacksb801439bbench: add typebox (compiled and dynamic) to the moltar cross-library harness by @colinhacks7ae49d64docs: drop the circle around the star pill's GitHub mark and center it on the pill's arc by @colinhacks93f3ab32docs: replace the blog navbar's GitHub icon with a star-count pill by @colinhacksfb2fedfddocs: tighten the memory chart callout, pad the canvas, say "less memory" by @colinhacksff56a551docs: center the memory chart callout labels and pad them off the number by @colinhacks8cd1250fdocs: center the memory chart callout labels by @colinhacks3195ed01docs: label the memory chart like the compile chart by @colinhacksa6b49390Mark the compile internals @internal instead of hiding them (#6518) by @colinhacks40b4d0b3fix(ci): read zod's latest version with npm view when picking the backfill dist-tag by @colinhacks5ff95665Stop re-exporting the compile internals from zod/v4/core (#6511) by @colinhacksf412178dci: publish @zod/mini to JSR in lockstep with npm (#6510) by @colinhacksf3e7c72efix(docs): render the docs 404 page inside the (doc) layout once by @colinhacksf3cb3644docs: surface the blog on the home page and in the sidebar by @colinhackscd4f9a67perf(v4): report Standard Schema issues without constructing a ZodError (#6509) by @colinhacks43b9bfc5docs: drop the bound-methods section from the Zod package page by @colinhacks70eb2c07docs: drop the traits section and the compilation feature bullet by @colinhacks1c0bce0cdocs: bring the 4.5 charts and worked examples into the docs pages by @colinhacksa0898b4bci: wait hours for npm to serve a publish, not ten minutes (#6502) by @colinhacksc46eeff0chore: narrow blanket biome-ignore comments (#6504) by @pullfrog[bot]c7ec94d3ci: check zod and @zod/mini lockstep on npm after every publish (#6507) by @colinhacks81065739chore(docs): build with Turbopack by @colinhacksabd41adbdocs(wiki): move plans and comparisons into a gitignored internal/ (#6506) by @colinhacks2956c4c2chore(mini): sync @zod/mini to 4.5.4 by @colinhacks8ce9e8d5feat(mini): publish Zod Mini as the standalone @zod/mini package (#6491) by @colinhacks93186cabdocs(wiki): drop the zod-compiler benchmark (#6505) by @colinhacks908c9e17fix(docs): retry the GitHub stars fetch and log the real status by @colinhacksv4.5.4Compare Source
Commits:
84e416ffix(v4): stop the cycle walk from firing a default factory (#6500)e8e206f4.5.4v4.5.3Compare Source
Commits:
e6b6ab3docs(blog): widen the z.compile example to a 20-property schema87d6464fix(docs): drop the OG description when the title wraps past two lines99fce39bench(v4): z.compile() against zod-compiler (#6499)e3a695bdocs(v4): record the email regex and container output-shape findings under Open7e24a24docs(blog): drop the reading time and put a GitHub link in the navbareab51fffix(v4): emit record numeric keys as strings in toJSONSchema (#6497)v4.5.2Compare Source
Commits:
a354314fix(docs): keep blog posts out of the docs collection (#6484)d378c42ci: drop canary publishing from the release workflow (#6487)212b941fix(v4): let a prototype method getter answer a bare call so vi.spyOn works (#6488)e7576f5docs(blog): let the page show through the navbar in dark mode (#6489)fedb06ffix(docs): match the blog TOC hover bar to the 2px active indicator6c932fcchore: bump devcontainer image to Node 24 (#6470)6635d9ddocs(blog): soften the "method memoization" attribution019ae29fix(docs): drop ISR on the docs route so the home page hydrates652bb43chore(docs): drop the scroll log from the route-change scroller571c8e8fix(docs): render blog tabs with the stock fumadocs tab card9a193aa4.5.2v4.5.1Compare Source
Commits:
2e862dbci: gate the GitHub release and JSR publish on the version being live on npm8e033804.5.1v4.5.0Compare Source
Zod 4.5 is now available.
At a glance:
z.compile()— the flagship feature of Zod 4.5z.creditCard()— 12–19 digits plus Luhn checksumz.properties()— the multi-property counterpart toz.property()z.deepPartial()/.exactPartial()z.validate(): boolean— a fast-path to verify input validity without a full parse (up to 16x faster on invalid data)bn), Central Kurdish (ckb), Hindi (hi), Kannada (kn), Norwegian Nynorsk (nn), Brazilian Portuguese (pt-BR), Slovak (sk), Turkmen (tk)z.compile()You can now pre-compile any Zod schema using
z.compile(schema). This dramatically speeds up parsing performance.A compiled schema can be used exactly like an uncompiled one. There are no special rules around compiled schemas. They're just faster.
On objects, arrays, and unions, this speeds up parsing by a factor of ~3–9. More complex schemas stand to benefit more than simpler ones.
Time per parse by schema type, standard parser vs compiled — lower is better (benchmark)
Below are the Moltar benchmark results comparing Zod (compiled and uncompiled) against the Moltar ParseSafe bench.
Throughput on the moltar benchmark fixture (parseSafe: returns a new object with unknown keys stripped) — higher is better (benchmark)
And the equivalent results for the Moltar AssertLoose bench. Tested against the new
z.validate(schema, input)function (detailed later in the post).Throughput on the moltar benchmark fixture (assertLoose: returns a boolean, unknown keys allowed) — higher is better (benchmark)
Zod's entire test suite runs twice—once normally and again with auto-compilation enabled globally—to ensure perfect fidelity.
How it works
Under the hood,
z.compile()walks the entire schema once and produces a hyperoptimized snippet of flat, loop-free JavaScript that can validate inputs far faster than a standard runtime validator. This snippet can be executed vianew Function()(effectively a more powerfuleval) to serve as a fast-path validator. Schemas use this to "fast check" validity, falling back to the regular runtime logic on validation failure to provide granular error information.Take this simple
Pointschema:Here is the generated snippet for it:
For the large majority of inputs, the generated function validates the data with the fastest logic JavaScript can express: straight-line
typeofchecks and property reads, with no interpreter in between. When it can't handle an input, Zod falls back to the standard parser.This is the function Zod generates for the
Playerschema above:Armed with the power of
new Function(), this happens in-process at runtime. There is no need to integrate with your build system.import "zod/compile"To compile every schema in an application, import
zod/compileonce at the top of your entry point. Every schema constructed after that import is automatically compiled the first time it's used to parse data.It also works as a Node.js CLI flag, which guarantees it runs before any module defines a schema:
Or set
preloadinbunfig.tomlornub.jsonc.All schemas benefit to varying degrees, though complex object/tuple/array schemas benefit more than simple scalar validators.
z.creditCard()A new string format: 12–19 digits, optionally separated by single spaces or hyphens, with a valid Luhn checksum. (#5931)
z.properties()The multi-property counterpart to
z.property(). (#5912)z.deepPartial()Back in functional form after being removed as a method in Zod 4. (#5928)
The result is still a
ZodObject, so.shapeand.extend()keep working..exactPartial()Like
.partial(), but wraps each field inz.exactOptional()instead ofz.optional(): keys may be omitted, but an explicitundefinedis rejected. This matches TypeScript'sPartial<>underexactOptionalPropertyTypes. (#6065)In Zod Mini it's a top-level function:
z.exactPartial(Recipe).z.validate()Standalone boolean validation, in Zod, Zod Mini, and Zod Core. It answers "is this input valid?" without constructing a
ZodError, which makes rejection cheap: on invalid input it is up to 16x faster than.safeParse().success. The return type is a guard on the schema's input type, andz.validateAsync()covers schemas with async refinements. (#6471)z.input()/z.output()Project a schema onto its input or output side. Useful for validating the two halves of a codec independently. (#5928)
This is a no-op on schemas not containing codecs/pipes.
z.toZod<T>()A utility to define a Zod schema that agrees exactly with a static type, often one that is handwritten or externally defined. (#5913)
z.getDiscriminatedOption()Extract a discriminated union member by discriminator value. (#5947)
Cyclical inputs
Zod recursive schemas now support cyclical data. For bundle size reasons, Zod Mini requires you to register a memoizer explicitly. (#6387, #6482)
Zod
Zod Mini
9x reduction in schema memory footprint
In Zod 4.4 a bare
z.string()retained 7.5kb of heap. In Zod 4.5 it retains 784 bytes.Retained heap per schema instance, Zod 4.4.3 vs 4.5 (benchmark)
In Zod 4.4 and earlier, all schema methods were automatically bound to the instance itself. This allowed users to pluck methods from schemas without causing issues due to
this-binding.A consequence of this is that each bound method allocates space on the heap; method implementations are not shared across all instances via
prototype, as you'd expect. Zod 4.5 implements a method memoization pattern that avoids allocating bound methods until they are actually accessed.Faster failures
Zod
.parse()/.safeParse()instantiates a JavaScriptError, which captures a stack trace. In the case of validation failures, this is often much slower than the parsing logic itself. When using.safeParse(), Zod no longer captures this stack trace, speeding up failure-path parses by a factor of ~7.5x. (#6316, #6450)Player schema (benchmark)
Symbol keys in
z.object()A shape can now declare a symbol key. TypeScript tracks it: a
constsymbol infers asunique symbol, soz.infermakes the key required and checks its value type. Undeclared symbol keys are still ignored. (#6448)Bug fixes
All of these fix soundness issues, so a schema that relied on the old behavior may now reject input it used to accept.
⚠️
z.iso.datetime()requires secondsRFC 3339 mandates seconds.
z.iso.datetime()andz.iso.datetime({ offset: true })no longer accept minute-precision input like2020-01-01T06:15Z.local: truestill admits2020-01-01T06:15, since an unqualified datetime is outside RFC 3339 either way. (#6457)To accept both forms, union the two precisions:
⚠️ String length counts code points
.min(),.max(), and.length()counted UTF-16 code units, soz.string().max(5)rejected five emoji. They now count Unicode code points, which is what every non-JS consumer of a length bound does (Postgres, MySQL, Go, Python, and themaxLengththatz.toJSONSchema()emits)..max()only loosens;.min()and.length()tighten for astral input. Graphemes are unchanged — a ZWJ sequence is still several code points. (#6441)Closes #3355.
⚠️ Record keys and intersections match TypeScript
A record's key schema now governs only the keys that match it, the way TypeScript treats an index signature. Intersecting an object with a pattern-keyed record no longer rejects the object's own keys. (#6412)
Separately, an
unrecognized_keysissue no longer aborts the schema it came from, so a strict object with an extra key and a bad value now reports both issues instead of just the first. Closes #2200, #2573, #4017, #5663.⚠️
__proto__is always strippedObject and record parsers now drop a
__proto__key whether it comes from the input, is declared by the schema, or is produced by a record key transform. A key that a record's key schema normalizes to__proto__is dropped too..strict()reports an own__proto__input key asunrecognized_keysinstead of silently swallowing it. Error formatters and both JSON Schema converters use own-property writes so atoStringorconstructorpath segment can't walk ontoObject.prototype(#6213, #6367, #6346). (#6386, #6354, #6355, #6221)⚠️ Stricter string formats
z.ipv6()validated by handing the string tonew URL(), which let::@1\and::1\nthrough. It now checks the address alphabet directly (#6442).z.ulid()restricts the first character to0–7; anything higher overflows the 48-bit timestamp. A fixture that doesn't start with a real timestamp, such as one with a leading letter, is now rejected (#6095).z.httpUrl()enforces the RFC 1035 length limits on the host, matchingz.hostname()(#6035).z.emoji()no longer backtracks exponentially on a failed match (#6347).z.string().includes(sub, { position: N })emits a JSON Schema pattern that allows at least N leading characters, matchingString.prototype.includes(#6024).Commits
Zod 4.5 rolls up 155 commits. Thanks to everyone who contributed: @dokson, @deepshekhardas, @zirkelc, @francisjohnjohnston-web, @MerlijnW70, @codinsonn, @oimo23, @JSap0914, @zelinewang, @abhishek-chaudhary2003, @spokodev, @Mohammad-Faiz-Cloud-Engineer, @hamed-bavar, @MGPOCKY, @ChiChuRita, @dinwwwh, @thristhart, @tsmartin9, @vedanshshetti, @belicam, @frastefanini, @andersk, @musaddiq-rafi, @tachmyratsaparmyradov, @arvindfroi, @KUMachine, @spidersouris, @catdalfonso, @mneetika, @gwagjiug, @MahinAnowar, @MaksZhukov, @emmayusufu, @agcty, @devareddy05, @Vish05, @yamcodes, @mattiasahlsen, @samchungy, @ozzyfromspace, @udohjeremiah, @patrickwehbe, @gajus, @Harm-Nullix, @thwbh, @IdanGonen, @irfanfandi, @JuerGenie, @marcalexiei, @itsahmedbilal, @DucMinhNe, @meliharik.
9782f87cperf(v4): validate without building the output, and keep schemas out of dictionary mode (#6480) by @colinhacks773a4867refactor(v4): declare a trait's members on $constructor (#6478) by @colinhacks68fb3f13feat(v4): make z.compile() fall back instead of throwing (#6479) by @colinhacks37b01501feat(v4): add z.isValid and z.isValidAsync (#6471) by @colinhacks749f5452docs: add fullproduct.dev to v4 ecosystem page (#6001) by @codinsonn24cdb7fdperf(v4): close the fastpass bindings into the compiled parser (#6464) by @colinhacks8d896186fix(v4): stop emitting a multipleOf that JSON Schema rejects (#6468) by @colinhacks43f729dbfeat(v4): make a tuple's items optional with .partial() (#6465) by @colinhacks97edaf7dfix(v4): don't throw from safeParse on bigint multipleOf(0n) (#6466) by @colinhacks21a6f0cbfeat(v4): let z.nanoid() take a custom length (#4004) by @oimo239d5b20effix(v4): restrict the first ULID character to [0-7] (#6095) by @JSap09141cf9cd09docs: record that error maps run per parse, and how to translate at render by @colinhacks7ce3e77dfix(v4): run a wrapper's inner schema on its own payload (#6462) by @colinhacks7b612b53fix(v4): fold an intersection of object schemas into one object (#6461) by @colinhacks1c43b774docs(v4): record why the failure path is not worth compiling by @colinhacksbadf0b78fix(v4): build the catch context from the input that failed (#6192) by @zelinewanga87ac366fix(v4)!: distinguish number and bigint formats at the type level (#6052) by @abhishek-chaudhary20036726c1dddocs: record what z.input and z.output do with transforms and wrappers by @colinhacks7cfc0122fix(v4): keep a wrapper's stored value only on the side it belongs to by @colinhacksa825c1b0fix(v4): empty enums and literals match nothing (#6459) by @colinhacks7c070db9feat(v4): expose the function schema on .implement() results (#6267) by @deepshekhardas3a496968fix(v4): make record input keys optional when the value can fill them (#6460) by @colinhacks53cec2a0fix(v4): resolve z.input past a preprocess transform by @colinhacks2125d30cfix(v4): accept exact decimal multiples in multipleOf (#6223) by @spokodev168122fcfix(v4): carry a pipe's own checks through z.output by @colinhacks51a1368afix(v4): let the includes(position) pattern match at or after the offset (#6024) by @francisjohnjohnston-web72a05c4ffeat(v4): expose stringbool truthy/falsy/case via _zod.bag (#6357) by @hamed-bavar036b39f4fix(v4)!: require seconds once a datetime carries a Z or an offset (#6457) by @colinhacks5825605eperf(v4): skip the eager stack capture when building a ZodError (#6450) by @colinhacksd85472c4feat(v4): support declared symbol keys in z.object() (#6448) by @colinhacksd4108872fix(v4): correct the date/time format keywords in both JSON Schema directions (#6452) by @colinhacks555e5f46Add z.toZod helper (#5913) by @colinhackse0e51a55docs(v4): cut the compile comments down to what they explain (#6449) by @colinhacks6574e784fix(v4): stop catch resurrecting issues an optional already resolved (#6440) by @colinhacks937b5d01perf(v4): prefix issue paths in place in the object JIT failure path (#6445) by @colinhacksb63db248fix(v4): keep a memoized node's cached issues private to the cache (#6443) by @colinhacks6ec3d043fix(resolution): keep pnpm's own warnings out of the attw snapshot (#6446) by @colinhacks830ba314fix(v4): validate the address, and return the string that was validated (#6442) by @colinhacksf101d8caPreserve callsites in parse stack traces (#5910) by @colinhacks6c77d028feat: compact simple anyOf unions to type array in toJSONSchema (#6339) by @deepshekhardas28e1ebd8fix(v4): measure string length in Unicode code points (#6441) by @colinhacks060bc9f3refactor: share default when-clauses for size/length checks (#6394) by @zirkelc2848177ddocs: point the flattened/formatted error deprecations at a symbol that exists by @colinhacks3c2dee9eAdd properties checks for instanceof schemas (#5912) by @colinhacks87ffeb0ffix(v4): an absent key on the middle rung supplies nothing (#6434) by @colinhacks7785fc82feat(v4): add z.getDiscriminatedOption (#5947) by @dokson0135c85afeat(v4): allow passing extra args to apply() (#6337) by @deepshekhardasca246d26fix(v4): drop empty alternation branch from datetime pattern (#6439) by @colinhackse073d55bdocs: z.iso.datetime() accepts a subset of ISO 8601, not all of it by @colinhacksd6ca12aefix(v4): infer recursive getter options in discriminatedUnion (#6422) by @colinhacksdc51404bAdd shorn to Zod Utilities (#6398) by @ChiChuRita580111dadocs: mark AOT compilation as canary-only by @colinhacks6b0dae79docs: note that a catch callback is not islanded by @colinhacks898c4461refactor(v4): give the runtime and compiled code one URL implementation by @colinhacks260e5d4bfix(v4): stop islanding a catch callback, which diverged silently by @colinhacks11c9268brevert(core): drop the exactOptional parse prototype from #6432 (#6438) by @colinhacksa38ab4a8fix(core): an omittable discriminator claims undefined (#6432) by @colinhacksc9ec89e0perf(core): drop the seal and the per-key WeakSet from the lazy internals (#6435) by @colinhacks3c9ca1d9feat(json-schema): emit a root $ref when the root schema has an id (#6029) by @dinwwwhfa77a4d7feat(v4): z.compile — ahead-of-time schema compilation (#6085) by @colinhacksf300476dfix(v4): let a schema's error map cover its own checks' issues (#6426) by @colinhacks9f0a3d81fix(core): restore defineLazy semantics lost in the internals move (#6429) by @colinhacks604464c3fix(locales): da/nn/no/sv called an IP address a range (#6430) by @colinhacks7378e7cdfix(locales): backfill the mac and Sizable.map gaps, and pin dictionary parity (#6427) by @colinhacksb1077f05perf(memory): install derived internals on a per-constructor prototype (#6415) by @colinhacksccc15144fix(locales): add the credit_card key to the seven locales missing it (#6424) by @colinhacks73bacbbbfix(from-json-schema): drop redundant inclusive bound for draft-04 exclusive ranges (#6022) by @francisjohnjohnston-web86b2e6dadocs: list el and hr in the supported locales (#6423) by @colinhacks45fdeda5fix(v4): refine optin into a three-rung ladder, retire the fallback payload flag (#6419) by @colinhacks5b34c0ceImprove Portuguese localization and add Brazilian Portuguese (pt-BR) (#6076) by @thristhartdc1a40a5fix(locales): improve french translation (#6120) by @tsmartin90175a043feat(locales): add Hindi and Kannada locale support (#6315) by @vedanshshetti536ee3b0Locales: added Slovak (sk) language (#6041) by @belicam07b0c3d8fix: preserve explicit superRefine issue input (#6053) by @frastefaniniba98071cfeat: add .exactPartial() to ZodObject (#6065) by @andersk234c407dfeat(lang): Added Bengali locale (#5974) by @musaddiq-rafi377cd9d7feat(locales): add turkmen (tk) locale (#6168) by @tachmyratsaparmyradov69b6bb08feat(locales): add Norwegian Nynorsk (nn) locale (#6092) by @arvindfroi33d82e6bAdd Central Kurdish (ckb) locale (#6078) by @KUMachine06666fe2fix(fr): remove hyphen in "non-optionnel" (#5999) by @spidersouris79cfedeafeat(v4): expose the owning schema on check-originated issues (#6420) by @colinhacks436b5da8docs: propose compiled constructor graph by @colinhackseb4682c9fix(json-schema): resolve tuple minItems past transform and catch in input mode (#6418) by @colinhacks4d6b5cd3fix(json-schema): route unrepresentable default values throughunrepresentableby @colinhacks2abc9e05docs: note that the JSON Schema emitter reads static optin (#6417) by @colinhacks578e1cd0feat(v4): support format: "hostname" in fromJSONSchema (#6305) by @catdalfonso942bf8cbfeat(v4): parse input containing reference cycles (#6387) by @colinhacks78b523f0fix(json-schema): keep preprocess object properties required in input mode (#6133) by @MerlijnW70973b1b44fix(v4): strip output-typed catch values from the input JSON Schema (#6409) by @colinhacks5e608851feat(v4): add z.deepPartial and runtime z.input / z.output (#5928) by @dokson4e1720c8fix(v4): align record keys and intersection strictness with TypeScript (#6412) by @colinhacks4cc4053dfix: honor loose mode for closed record key schemas (#6157) by @pullfrog[bot]69be843ffix(v4): stop the object JIT fastpass keeping a swallowed issue's value (#6407) by @colinhacksb899cd17perf(json-schema): make toJSONSchema(registry) linear in registry size (#6408) by @colinhacks6074828efix(v4): make fromJSONSchema propertyNames compose with the other object keywords (#6411) by @colinhacksd7b209f3docs: point the Web URLs callout at z.httpUrl() (#6410) by @colinhacks611bd762fix(mini): make merge() take an object schema, matching classic (#6404) by @colinhacksb53e53ccfix(v4): use exact flag in English locale too_small/too_big messages (#6177) by @pullfrog[bot]421cc9a5fix(json-schema): unescape JSON Pointer tokens when resolving $ref (#6402) by @colinhacks4c27fe87fix(v4): give z.xor() a distinct error when multiple options match (#6376) by @colinhacksa106fbe7fix(v4): make fromJSONSchema tuples open-ended by default (#6020) by @mneetikae8034ebafix(v4): make prefixItems/draft-7 items respect minItems in fromJSONSchema (#6201) by @pullfrog[bot]784e5c26fix(v4): let bundlers tree-shake locales out of the default import (#6384) by @colinhacks97edd70afix(toJSONSchema): constrain closed tuple length (#6194) by @pullfrog[bot]f150020dfix(v4): escape non-string enum values in template literal patterns (#5934) by @gwagjiugfaf33a28fix: surface @deprecated on re-exported compat aliases (#6072) by @MahinAnowar3956224adocs: state that metadata wins over generated JSON Schema keywords (#6401) by @colinhacksa1904fc2fix(v4): report date origin for numeric min/max bounds (#6129) by @MerlijnW70bd18314cfix: escape JSON Pointer reserved characters in toJSONSchema $ref (closes #6027) (#6144) by @MaksZhukov2a5164f5fix(v4): enforce RFC 1035 length limits in regexes.domain (#6035) by @emmayusufu0e5bc4b1fix(v4): respect additionalProperties:false with patternProperties in fromJSONSchema (#6199) by @pullfrog[bot]c8f06d36fix(v4): clarify infinite number errors (#5906) by @colinhacks9a7ecc35fix(json-schema): accept RFC 3339 numeric offsets in date-time format (#6298) by @agcty0a76f3d7feat(v4): add z.creditCard() string format (#5931) by @doksonbd6619c0feat(json-schema): accept a function forunrepresentable(#6380) by @colinhacks9d20fdc3fix(v4): preserve z.preprocess input narrowing (#5967) by @devareddy053063993aperf(v4): cut per-schema memory ~90% by moving methods to the prototype (#6318) by @zirkelcfd074106feat(json-schema): runoverridebefore the unrepresentable error (#6391) by @colinhacks2715c12efix(v4): preserve default English locale across tree-shaken bundles (#5959) by @colinhacks81d9fc6cdocs: add zod-form-action to ecosystem (#6314) by @Vish05d86df5e0docs: add ArkEnv to ecosystem page (#6203) by @yamcodes18b4ff99docs(ecosystem): add zodql to API Libraries (#6227) by @mattiasahlsen479d6f51shill oxlint (#6196) by @samchungy85dba7e1docs: document that any/unknown object keys are required (#6388) by @colinhacksd24fb4c3fix: consistently strip proto from parsed objects (#6386) by @colinhacks7708d447perf(v4): lazy ZodError construction (#6316) by @zirkelc8ac9ae51fix(docs-v3): serve the docsify SPA fallback on Vercel (#6378) by @colinhacks31384464fix(v4): complete reserved-key hardening (#6371) by @colinhacks600c6909docs: add Attaform to ecosystem (#6188) by @ozzyfromspace37c05fa5docs(ecosystem): rename zod-to-mongo-schema to zod-mongo-schema (#6178) by @udohjeremiahbadfdf08docs: update keyof() ZodEnum type to the v4 form (#6124) by @patrickwehbee25b68e1perf(v4): let three dead declarations tree-shake under esbuild (#6381) by @colinhacks53397351docs(ecosystem): Add zod-mongoose list item in Zod To X (#6062) by @Harm-Nullixdfa0deb1docs: add tauri-typegen to ecosystem (#6032) by @thwbh9c914ee8docs: add dynamic error message and combined refinement examples for refine() (#6002) by @IdanGonen921649defix(v4): formatError and treeifyError handle inherited-name path elements (#6367) by @deepshekhardase7029aa4fix(v4): report own proto key under .strict() (#6221) by @pullfrog[bot]9c540db8fix(v4): re-check the record key after the key schema runs (#6355) by @colinhacks8bb89ea4docs: add .nonempty() to Strings, Arrays, Sets, and Maps sections (#6056) by @pullfrog[bot]599c0e41docs(ecosystem): Add@chrock-studio/overloadand@chrock-studio/zod-utils(#6040) by @JuerGenie27a9036adocs(ecosystem):eslint-plugin-zodiseslint-zodnow (#5975) by @marcalexieie177a0eedocs(v4): document coerce missing-key breaking change (#5957) (#5964) by @dokson66fba964docs: show z.instanceof with built-in classes (#6059) by @itsahmedbilal2d90846afix(docs): make the prefault example runnable (#6063) by @DucMinhNeead9fcb3fix(v4): write a declared proto key as an own property (#6354) by @colinhacksc58764c5docs: fix UUID helper list in v4 introduction (#6214) by @meliharikf238fbd2fix: remove exponential backtracking from the emoji regex (#6347) by @colinhackse6c213ecfix(json-schema): keep proto keys as own properties in schema conversion (#6346) by @colinhacks573fcb75fix(errors): use own-property semantics in every error-tree walker (#6213) by @pullfrog[bot]6f5e99fdfix(docs-v3): rename README.md to home.md so Vercel serves it by @colinhacksbbc68f99docs: soften Zod 3 EOL callouts to informational tone by @colinhacks3fc9b25fdocs: reframe library-authors page Zod-4-first; note Zod 3 EOL by @colinhacksf29f2a6dfix(v4): cidrv6 JSON schema pattern matches runtime (#5945) by @doksondfd8766bfix(v4): break circular import between classic schemas and iso (#5275) (#5926) by @doksonfbe8ad1bfix(v4): allow dynamic.catch()underunrepresentable: "any"(#5273) (#5925) by @doksonConfiguration
📅 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 CLI.
f51b639301to0e6df33faaUpdate dependency zod to v4.5.2to Update dependency zod to v4.5.40e6df33faatoe24ab9ca22Update dependency zod to v4.5.4to Update dependency zod to v4.6.1e24ab9ca22tocd212faeb6Update dependency zod to v4.6.1to Update dependency zod to v4.6.2cd212faeb6toecd8e438a7Update dependency zod to v4.6.2to Update dependency zod to v4.6.4ecd8e438a7toc094dc6c31Update dependency zod to v4.6.4to Update dependency zod to v4.6.5View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.