-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Update dependency zod to v4 (main) #205555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Pinging @elastic/security-solution (Team: SecuritySolution) |
7495f41 to
a2edb91
Compare
a2edb91 to
bad78d7
Compare
bad78d7 to
ecd8d5b
Compare
ecd8d5b to
fddd7cb
Compare
|
/ci |
|
This appears to be blocked on errors in the |
fddd7cb to
624edae
Compare
624edae to
bded6fb
Compare
bded6fb to
820eecf
Compare
820eecf to
e5c30c7
Compare
e5c30c7 to
af471aa
Compare
af471aa to
21b562c
Compare
21b562c to
557ded0
Compare
e5b7157 to
555eebc
Compare
4d0e3fe to
a38cc4c
Compare
5f844ae to
61a4aa6
Compare
Seems like this renovate PR should help: #229504 |
2006eab to
3eefe5e
Compare
3eefe5e to
fbe71ae
Compare
|
When I was working on |
Edited/Blocked NotificationRenovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR. You can manually request rebase by checking the rebase/retry box above. |
19679aa to
26faf84
Compare
💔 Build Failed
Failed CI StepsHistory
|
This PR contains the following updates:
^3.22.3->^4.1.54.1.9(+3)Release Notes
colinhacks/zod (zod)
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,
[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.xrelease and4.0.0. This does not require a major version bump.v4.0.0Compare Source
v3.25.76Compare Source
Commits:
91c9ca6fix: cleanup _idmap of $ZodRegistry (#4837)9cce1c5docs: fix typo in flattenError example on error-formatting page (#4819) (#4833)a3560aev3.25.76 (#4838)5060661Release 3.25.767baee4eUpdate index.mdx (#4831)v3.25.75Compare Source
Commits:
c5f349bFix z.undefined() behavior in toJSONSchemav3.25.74Compare Source
Commits:
ae0dbe1Partial record39c5f713.25.74v3.25.73Compare Source
Commits:
1021d3cv3.25.73 (#4822)v3.25.72Compare Source
Commits:
4a4dac7Warn about id uniqueness check on Metadata page (#4782)7a5838dfeat(locale): Add Esperanto (eo) locale (#4743)36fe14eFix optionality of schemas (#4769)20c8c4bFix re-export bug8b0df103.25.72v3.25.71Compare Source
Commits:
66a0f34Move source to/src(#4808)2a15f443.25.71v3.25.70Compare Source
Commits:
bd81c7cAdd ecosystem listing to homepage1ddb971Add Mobb to sponsors30ba440Clean up ecosystem.mdx0ef1b85Addsvelte-jsonschema-formto form integrations (#4784)14715f1docs: fix Lambda spelling (#4804)f6da030Add back src (#4806)364200aRevert "Add back src (#4806)"16e1b67v3.25.70 (#4807)v3.25.69Compare Source
Commits:
f46946cImprove release workflowb6fe831Do not clobber defaults in7f986d0Skip attw test if Zod isn't built5576182Addexacttotoo_big/too_smallissue formats (#4802)8fd2fc33.25.69v3.25.68Compare Source
Commits:
d3e0f86feat: add zod-xlsx back to the ecosystem.tsx (#4718)86112d9chore: update lint-staged from v12 to v16 (#4703)218a267chore: remove unused octokit (#4708)a7cb6edfix(v4): add exact to length check issue (#4617)b888170Close #40355879bafFix fmtbd1bddaFix buildddadfb8Simplify basics, document reportInputd5e2368Addz.stringFormat()(#4737)ee5615dDrop example and examples entirely4080fd9Add treeshaking discussion to docscf6157aDocs39947acUse import star everywhere7e296aeWIPbb42be4Update treeshake target0a49fa3Improve mini docs1b0a5e5Add dep90fa0cdSwitch tozshy(#4777)af3841bRename play.tscf12ccf3.25.6834ae421Update snapshotv3.25.67Compare Source
Commits:
7afe790Make $ZodLiteralDef generic91274c33.25.67c22944bFix race conditionv3.25.66Compare Source
Commits:
2b3e87bUpdate api.ts (#4724)100e9aachore: include zod-validation-error to Ecosystem page (#4722)de3517efix(docs): prevent FOUC on website homepage logo (#4716)222a663Change ZodObject default to $strip. Set inst.shape in zod minifb006183.25.66v3.25.65Compare Source
Commits:
6530994Clean up ecosystem131fdbdfix(docs): Use array as argument of templateLiteral (#4701)ed648b1chore: remove deprecated @types/chalk (#4685)12dd489Add catchall to zod-minifcb722aAdd uuid to changelog8c740353.25.65v3.25.64Compare Source
Commits:
b142ea8Fix $stripb6e59c3Check for existence of Error.captureStackTrace0c686afRemove type from mime issue pathaf88d74Fix testv3.25.63Compare Source
Commits:
7ed0c36Allow hours-only offsets. Normalize. (#4676)112fff6Fix iso tests6176dcbImprove ISO second handling (#4680)8e20a20Use consistent variable names for IP examples (#4679)29e4973refactor: remove unnecessary assertion (#4672)c626fe1chore: update husky from v7 to v9 (#4682)f350a693.25.63v3.25.62Compare Source
Commits:
c568deaDrop | undefined from json schema types1614fd83.25.62v3.25.61Compare Source
Commits:
1c2ad87Loose signature for index signature shapesafa7e673.25.6182b43faFix testv3.25.60Compare Source
v3.25.59Compare Source
Commits:
aec5c4aFix formattingd3389cbrefactor: change if in else to else if (#4664)ffc41bdImprove JSON Schema typingv3.25.58Compare Source
Commits:
21ee3f6Add Zod Sockets to Ecosystem (#4655)6707ebbv4: Preserve function types in.meta()(#4636)3cecd98Added Superforms for SvelteKit (#4635)305399fFix adjectives in Japanese (#4648)04dc83efeat(locale): Add Pashto (ps) locale support (#4594)ed933d9refactor: remove unused import & imported multiple times (#4588)0d87aa4Make id lazyf98ed6dnpmrc7262301remove external2904af23.25.58v3.25.57Compare Source
Commits:
daae643docs: fix broken link in Zod Core errors docs (#4640)e57ddcaReplace non existing error instance. (#4649)20b464dAdd tests, use ReadonlyArray9548f11chore: allow readonly arrays inz.literal(#4643)303f1e9fix: issc type at ZodCheckLessThan (#4659)fa83a8aFix pluto32ae1cdImprove stringbool (#4661)76ddfe33.25.57v3.25.56Compare Source
Commits:
64bfb703.25.56v3.25.55Compare Source
Commits:
44141ea3.25.55v3.25.54Compare Source
Commits:
8ab2374fix(util): cross realm IsPlainObject check (#4627)2be1c6aFix generic assignability issue. 3.25.54v3.25.53Compare Source
Commits:
a6adb14zod mini internals (#4631)da4f9213.25.53v3.25.52Compare Source
Commits:
2954f40Fix json (#4630)51dc6f93.25.52e479ea7Add test cast for deferred self-recursionv3.25.51[Compare Source](https://redirect.github.com/colinh
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), 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.