build: update dependency zod to v4 #12
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
^3.23.8
->^4.0.0
Release Notes
colinhacks/zod (zod)
v4.1.9
Compare Source
Commits:
a78716d
Update zshy (#5249)923af80
Publish zod@4.1.9v4.1.8
Compare Source
Commits:
36c4ee3
Switch back to weakmapa1726d5
4.1.8v4.1.7
Compare Source
Commits:
0cca351
Fix variable name inconsistency in coercion documentation (#5188)aa78c27
Add copy/edit buttons76452d4
Update button txt937f73c
Fix tsconfig issue in bench976b436
v4.1.6 (#5222)4309c61
Fix cidrv6 validation - cidrv6 should reject invalid strings with multiple slashes (#5196)ef95a73
feat(locales): Add Lithuanian (lt) locale (#5210)3803f3f
docs: update wrong contents in codeblocks inapi.mdx
(#5209)8a47d5c
docs: update coerce example inapi.mdx
(#5207)e87db13
feat(locales): Add Georgian (ka) locale (#5203)c54b123
docs: adds@traversable/zod
and@traversable/zod-test
to v4 ecosystem (#5194)c27a294
Fix two tiny grammatical errors in the docs. (#5193)23a2d66
docs: fix broken links in async refinements and transforms references (#5190)845a230
fix(locales): Add type name translations to Spanish locale (#5187)27f13d6
Improve regex precision and eliminate duplicates in regexes.ts (#5181)a8a52b3
fix(v4): fix Khmer and Ukrainian locales (#5177)887e37c
Update slugse1f1948
fix(v4): ensure array defaults are shallow-cloned (#5173)9f65038
docs(ecosystem): add DRZL; fix Prisma Zod Generator placement (#5215)aa6f0f0
More fixes (#5223)aab3356
4.1.7v4.1.6
Compare Source
v4.1.5
Compare Source
Commits:
530415f
Update docsb7b081d
Update z.function() type to support array input (#5170)780cf57
4.1.5v4.1.4
Compare Source
Commits:
3291c61
fix(v4): toJSONSchema - wrong tuple withnull
output when targetingopenapi-3.0
(#5156)23f41c7
test(v4): toJSONSchema - usevalidateOpenAPI30Schema
in all relevant scenarios (#5163)0a09fd2
Update installation instructions4ea5fec
4.1.4v4.1.3
Compare Source
Commits:
98ff675
Drop stringToBooleana410616
Fix typo0cf4589
fix(v4): toJSONSchema - add missing oneOf inside items in tuple conversion (#5146)8bf0c16
fix(v4): toJSONSchema tuple path handling for draft-7 with metadata IDs (#5152)5c5fa90
fix(v4): toJSONSchema - wrong record output when targetingopenapi-3.0
(#5141)87b97cc
docs(codecs): update example to use payloadSchema (#5150)309f358
fix(v4): toJSONSchema - output numbers with exclusive range correctly when targetingopenapi-3.0
(#5139)1e71ca9
docs: fix refine fn to encode works properly (#5148)a85ec3c
fix(docs): correct example to useLooseDog
instead ofDog
(#5136)3e98274
4.1.3v4.1.2
Compare Source
Commits:
e45e61b
Improve codec docs25a4c37
fix(v4): toJSONSchema - wrong record tuple output when targetingopenapi-3.0
(#5145)0fa4f46
Use method form in codecs.mdx940383d
Update JSON codec and docs3009fa8
4.1.2v4.1.1
Compare Source
Commits:
648eb43
Remove codecs from sidebare7e39a99
Improve codec docse5085be
Add images028b289
Add methods10cc994
4.1.1v4.1.0
Compare 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->A
and executes theencode
transform during encodingB->A
instead ofA->B
The 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.
stringToBigInt
Converts
bigint
into a serializable form.json
Parses/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:
stringToNumber
stringToInt
stringToBigInt
numberToBigInt
isoDatetimeToDate
epochSecondsToDate
epochMillisToDate
jsonCodec
utf8ToBytes
bytesToUtf8
base64ToBytes
base64urlToBytes
hexToBytes
stringToURL
stringToHttpURL
uriComponent
stringToBoolean
.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 literallyextend
the original type (in the TypeScript sense).To enforce true
extends
logic, 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$ZodFunction
is now a subtype of$ZodType
Commits
edd4fea
- Closes #51275d4a315
- Closes #5116f3f0955
- Closes #51080114d5b
- #51223b077c3
- #51211e06af8
- #5113b01b6f3
— #5052571ab0c
— #5051d3ea111
— #5049b8e3f87
— #4865v4.0.17
Compare Source
Commits:
1cebf33
Add blog (#5074)fc1e556
Fixes #5073cc63f95
v4.0.17v4.0.16
Compare Source
Commits:
d589186
fix: ensure keyof returns enum (#5045)4975f3a
feat: add discriminator generic (#5044)0a463e3
Update speakeasy files12658af
Fix Edit page buttons47e6604
fix:edit this page
button, now redirects to correct url using the new path (#5056)7207a2d
Update Hey API link to Zod v3 plugin (#5060)6887ff3
Update Hey API link to Zod plugin (#5059)ffff1aa
Clone POJO objects during defaulting/prefaultinga227cb3
v4.0.16v4.0.15
Compare Source
Commits:
7e7e346
Clean up docsf2949a8
[docs] Fix migration guide upgrade command (#5021)d43cf19
Fix recursive object initialization errors with check() and other methods (#5018)3de2b63
fix: remove redundant Required<> from input and output type definitions (#5033)93553bd
Add needs info03cfa8d
4.0.15v4.0.14
Compare Source
Commits:
99391a8
Docs: Fix typo (#5005)e25303e
Docs: fix typo (#5008)dbb05ef
Add JSON Schema draft-04 output (#4811)b8257d7
Improve tuple recursive inference.9bdbc2f
Avoid infinite loops in defineLazy. Fixes #4994.af96ad4
4.0.14v4.0.13
Compare Source
Commits:
362eb33
Fix optional + pipe handling. Closes #5002. v4.0.13v4.0.12
Compare Source
Commits:
ff83fc9
Add eslint-plugin-import-zod (#4848)7c9ce38
Update docs for z.property check (#4863)c432577
docs: add jwt schema docs (#4867)35e6a6f
Add llms.txt (#4915)3ac7bf0
Clean up Edit this Page60a9372
Implementllms-full.txt
(#5004)73a1970
4.0.12v4.0.11
Compare Source
Commits:
8e6a5f8
Fix “Edit on Github” link (#4997)930a2f6
Fix number of errors in doc (#4993)c762dbb
feat(locale): Add Yoruba (yo) locale (#4996)9a34a3a
Zod 4.0.11 (#4981)v4.0.10
Compare Source
Commits:
291c1ca
Add should-build scripte32d99b
Move should-build scriptd4faf71
Add v3 docs (#4972)dfae371
Update Jazz img on v3 docsd6cd30d
fix #4973 (#4974)1850496
Fix typo invalype
(#4960)4ec2f87
Add Zod Playground to zod 4 ecosystem (#4975)2b571a2
Update docs z.enum with object literal example (#4967)813451d
v4.0.10 (#4978)v4.0.9
Compare Source
Commits:
4e7a3ef
v4.0.9 (#4970)v4.0.8
Compare Source
Commits:
3048d14
Fix #4961v4.0.7
Compare Source
Commits:
7ab1b3c
Do not continue parsing in ZodPipe if issues exists. Closes #4926.34b400a
4.0.7v4.0.6
Compare Source
Commits:
a3e4391
Unwiden catch input type (#4870)499df78
Add RFC 9562 mentions. Closes #4872d0493f3
Doc tweak - spread vs destructuring (#4919)8dad394
feat: Icelandic translation (#4920)2ffdae1
Bulgarian (bg) translation (#4928)0973135
docs: add valype to xToZodConverts (#4930)d257340
Remove moduleResolution callout (#4932)075970d
docs: add coercion note to fix compile errors (#4940)b9e8a60
Add@hey-api/openapi-ts
to Zod 3 ecosystem (#4949)ad7b0ff
Add@hey-api/openapi-ts
to Zod 3 ecosystem (#4942)4619109
feat(locales): add Danish translations (#4953)cb84a57
Point to zod-v3-to-v4 codemod in Zod 4 migration guide (#4954)28a5091
Update api.mdx (#4955)7f3cf94
Fix URL sup example (#4959)17e7f3b
Add@hey-api/openapi-ts
to Zod 4 ecosystem (#4950)f75d852
fix: escapes decimal place inz.literal
(#4895)7dd7484
v4.0.6 (#4941)v4.0.5
Compare Source
Commits:
f91a73e
Support pipes in discriminated unions. Closes #4856 (#4861)45afab0
4.0.5v4.0.4
Compare Source
Commits:
9335f05
AddsZodFirstPartyTypeKind
stub to fix module resolution failure insidezod-to-json-schema
v4.0.3
Compare Source
Commits:
5905a8d
Improve check-versions scriptf3e749b
Remove global File interface44a936c
4.0.274006ed
Fix JSR provenanceff4af5e
4.0.3ce573e8
Update test badge9a7161a
Fix versionsv4.0.2
Compare Source
v4.0.1
: v4.0.0Compare Source
With this release,
[email protected]
has 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 [email protected] 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.x
release and4.0.0
. This does not require a major version bump.v4.0.0
Compare Source
Configuration
📅 Schedule: Branch creation - "after 10:00pm every weekday,before 5:00am every weekday,every weekend" in timezone America/Tijuana, Automerge - At any time (no schedule defined).
🚦 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 Renovate Bot.