zod 3.22.0
ZodReadonly
This release introduces ZodReadonly and the .readonly() method on ZodType.
Calling .readonly() on any schema returns a ZodReadonly instance that wraps the original schema. The new schema parses all inputs using the original schema, then calls Object.freeze() on the result. The inferred type is also marked as readonly.
const schema = z.object({ name: string }).readonly();
type schema = z.infer<typeof schema>;
// Readonly<{name: string}>
const result = schema.parse({ name: "fido" });
result.name = "simba"; // error
The inferred type uses TypeScript's built-in readonly types when relevant.
z.array(z.string()).readonly();
// readonly string[]
z.tuple([z.string(), z.number()]).readonly();
// readonly [string, number]
z.map(z.string(), z.date()).readonly();
// ReadonlyMap<string, Date>
z.set(z.string()).readonly();
// ReadonlySet<Promise<string>>
Commits:
- 6dad90785398885f7b058f5c0760d5ae5476b833 Comments
- 56ace682e4cc89132c034a3ae2c13b2d5b1a0115 Fix deno test
- 3809d54fc8c5dd0a0ce367bd2575fe3fdadf087d Add superforms
- d1ad5221900af640bc3093a2fb0476ec0c94953e Add transloadit
- a3bb701757127ffe05e773a2e449136b9b7efcb3 Testing on Typescript 5.0 (#2221)
- 51e14beeab2f469fcbf18e3df44653e1643f5487 docs: update deprecated link (#2219)
- a263814fc430db8d47430cd2884d2cea6b11c671 fixed Datetime & IP TOC links
- 502384e56fe2b1f8173735df6c3b0d41bce04edc docs: add mobx-zod-form to form integrations (#2299)
- a8be4500851923aa865e009fe9c2855e80482047 docs: Add
zockerto Ecosystem section (#2416) - 15de22a3ba6144c7d8d2276e8e56174bcdfa7225 Allow subdomains and hyphens in
ZodString.email(#2274) - 00f5783602ccbe423deb0dbd76ecf13a276bc54d Add
zod-openapito ecosystem (#2434) - 0a17340e9fc4b909d10ca3687b6bc6454903ff21 docs: fix minor typo (#2439)
- 60a21346086d32ca9f39efc2771f5db37c835c03 Add masterborn
- 0a90ed1461dafa62ff50ce0d5d5434fd4a2a4a20 chore: move
exports.typesfield to first spot @ package.json. (#2443) - 67f35b16692ca33fd48adfec9ae83b9514f8a4b7 docs: allow Zod to be used in dev tools at site (#2432)
- 6795c574b1d34f6e95ae891f96d8b219b98ace92 Fix not working Deno doc link. (#2428)
- 37e9c550460e4edd144da90d903e878c119c5cc1 Generalize uuidRegex
- 09699501ff6218b3b0a7e382eca3c02a8226ce13 adds ctx to preprocess (#2426)
- af08390139cf9fd4fc9e398b60a39191bf224076 fix: super refinement function types (#2420)
- 36fef58410f4b2c9e79edabae2fc567a4aee13a7 Make email regex reasonable (#2157)
- f627d14d3bfe3a680ac0d54705b2e63daa912aed Document canary
- e06321c15d22082e47c7c111a92ec7b3e104c644 docs: add tapiduck to API libraries (#2410)
- 11e507c4d3bf4ad3ab2057a0122168ed0048a2c4 docs: add ts as const example in zod enums (#2412)
- 5427565c347a14056bc60e3ffd800b98753952bc docs: add zod-fixture to mocking ecosystem (#2409)
- d3bf7e60a8eb706c4c63a9a91fd66565b82883cf docs: add
zodockto mocking ecosystem (#2394) - 2270ae563f7f14bed770f75d9c252880794fa71f remove "as any" casts in createZodEnum (#2332)
- 00bdd0a7ffdf495af14e67ae1396c85a282c38dd fix proto pollution vulnerability (#2239)
- a3c525658bc43edf40747a99b8f882d8d3d1e0c7 Fix error_handling unrecognized_keys example
- 4f75cbc682199a5411189f9cd9abba9af4924746 Adds getters to Map for key + value (#2356)
- ca7b03222764496d72085b1178fa22f4a57fe579 FMC (#2346)
- 6fec8bd3407f463f157522a3979b4d202870ba4c docs: fix typo in link fragment (#2329)
- 16f90bd22b465aca9a1fbad09248d80aa93fd824 Update README.md
- 2c802507d92d2d2e15be959695b1de78b896bfcb Update readme
- eaf64e09ba1a87dd6bf348fb97061894a01242d2 Update sponsors
- c5763112e2912390f3317d738e4261fa8747494e Update readme
- 5e23b4fae4715c7391f9ceb4369421a034851b4c Add
*.mdpattern to prettier (#2476) - 898dced470f1045b5469543abd2f427a713d93eb Revamp tests
- 6309322a28545e316299f8b9a36f43132d347300 Update test runners
- c0aece1672d1442d69ce1991142af8f16ed20ecb Add vitest config
- 73a5610186c413872153e8dcac76c4c4f23dfe4e Update script
- 8d8e1a2d306cecaf3d8cb88f32fe3e130a834f9f Fix deno test bug
- 9eb2508fac78cc36faefd050e9616bb6d34814c1 Clean up configs
- cfbc7b3f6714ced250dd4053822faf472bf1828e Fix root jest config
- 8677f688b0ab1bb5991e90744f46a15082772bd6 docs(comparison-yup): Yup added partial() and deepPartial() in v1 (#2603)
- fb00edd04ca338b8d791a96dead161076538c6c2 docs: add VeeValidate form library for Vue.js (#2578)
- ab8e71793431eeb163613007c134132e6c2ab078 docs: fix typo in z.object (#2570)
- d870407a020f9518fbae662f9f48a9aba005a3e2 docs: fix incomplete Records example (#2579)
- 5adae24e9b2fc98fc679defa8f78e4142d4c3451 docs: add conform form integration (#2577)
- 8b8ab3e79691ebafbb9aac3ce089eaf0dcd6d8fe Update README.md (#2562)
- 6aab9016873c12be08d19bcc097b3e5ba4c9d6fe fix typo test name (#2542)
- 81a89f593f4d6b05f770bbb3ad0fc98075f468dd Update nullish documentation to correct chaining order (#2457)
- 78a409012a4dc34a455f5c4a7e028ca47c921e1b docs: update comparison with
runtypes(#2536) - 1ecd6241ef97b33ce229b49f1346ffeee5d0ba74 Fix prettier
- 981d4b5e272e7e35ff44a31fbb5e8e90594b1933 Add ZodReadonly (#2634)
- fba438cddea800b081a15aefc8b1efea2eccf7af 3.22.0