Zod 4.5
Zod 4.5 现已发布
概览:
z.compile()— Zod 4.5 的旗舰功能z.creditCard()— 12–19 位数字加上 Luhn 校验和z.properties()—z.property()的多属性对应项z.deepPartial()/.exactPartial()z.validate(): boolean— 无需完整解析即可验证输入有效性的快速路径(对无效数据最多快 16 倍)- Schema 内存占用减少 9 倍
- 新增 locale:Bengali(
bn)、Central Kurdish(ckb)、Hindi(hi)、Kannada(kn)、Norwegian Nynorsk(nn)、Brazilian Portuguese(pt-BR)、Slovak(sk)、Turkmen(tk)
z.compile()
现在可以使用 z.compile(schema) 预编译任意 Zod schema。这会显著提升解析性能。
编译后的 schema 可以完全像未编译的 schema 一样使用。对于编译后的 schema 没有任何特殊规则。它们只是更快。
对于对象、数组和联合类型,解析速度可提升约 3–9 倍。越复杂的 schema,收益通常越大。
下面是 Moltar 基准测试结果,将 Zod(编译和未编译)与 Moltar ParseSafe 基准进行比较。
以下是 Moltar AssertLoose 基准的对应结果。测试使用了新的 z.validate(schema, input) 函数(将在本文后面详细介绍)。
Zod 的整个测试套件会运行两次——一次正常运行,另一次在全局启用自动编译的情况下运行,以确保完全一致。
import "zod/compile"
要在应用中编译每个 schema,请在入口点顶部导入一次 zod/compile。在该导入之后构造的每个 schema,都会在第一次用于解析数据时自动编译。
它也可以作为 Node.js CLI 标志使用,这可以保证它在任何模块定义 schema 之前运行:
或者在 bunfig.toml 或 nub.jsonc 中设置 preload。
所有 schema 都会在不同程度上受益,不过复杂的对象/元组/数组 schema 比简单的标量验证器受益更多。
z.compile()z.creditCard()
一种新的字符串格式:12–19 位数字,可选择使用单个空格或连字符分隔,并带有有效的 Luhn 校验和。(#5931)
z.properties()
z.property() 的多属性对应项。(#5912)
z.deepPartial()
在从 Zod 4 中移除为方法后,以函数形式回归。(#5928)
结果仍然是一个 ZodObject,因此 .shape 和 .extend() 仍可继续使用。
.exactPartial()
类似于 .partial(),但会将每个字段包装在 z.exactOptional() 而非 z.optional() 中:键可以省略,但显式的 undefined 会被拒绝。这与启用 exactOptionalPropertyTypes 时 TypeScript 的 Partial<> 相匹配。(#6065)
在 Zod Mini 中,它是一个顶层函数:z.exactPartial(Recipe)。
z.validate()
独立的布尔值验证功能,适用于 Zod、Zod Mini 和 Zod Core。它无需构造 ZodError,即可回答“这个输入是否有效?”,因此拒绝输入的成本很低:对于无效输入,其速度最多比 .safeParse().success 快 16 倍。返回类型是针对 schema 输入类型的类型守卫,而 z.validateAsync() 则覆盖带有异步 refinement 的 schema。(#6471)
z.input() / z.output()
将 schema 投影到其输入端或输出端。适用于独立验证 codec 的两端。(#5928)
对于不包含 codecs/pipes 的 schema,这是一个空操作。
z.toZod<T>()
用于定义一个与静态类型完全一致的 Zod schema,通常适用于手写或外部定义的类型。(#5913)
z.getDiscriminatedOption()
根据 discriminator 值提取判别联合成员。(#5947)
循环输入
Zod 的递归 schema 现在支持循环数据。出于 bundle 大小的考虑,Zod Mini 要求显式注册 memoizer。(#6387、#6482)
Schema 内存占用减少 9 倍
在 Zod 4.4 中,一个简单的 z.string() 会保留 7.5kb 的堆内存。在 Zod 4.5 中,它只保留 784 字节。
在 Zod 4.4 及更早版本中,所有 schema 方法都会自动绑定到实例自身。这使用户可以从 schema 中提取方法,而不会因 this 绑定造成问题。
这样做的一个后果是每个绑定的方法都会在堆上分配空间;正如预期的那样,方法实现不会通过 prototype 在所有实例之间共享。Zod 4.5 实现了一种方法 memoization 模式,避免在绑定方法实际被访问之前分配它们。
更快的失败处理
Zod 的 .parse()/.safeParse() 会实例化一个 JavaScript Error,该操作会捕获堆栈跟踪。在验证失败的情况下,这通常比解析逻辑本身慢得多。使用 .safeParse() 时,Zod 不再捕获此堆栈跟踪,使失败路径上的解析速度提升约 7.5 倍。(#6316、#6450)
z.object() 中的 Symbol 键
现在 shape 可以声明 Symbol 键。TypeScript 会对其进行跟踪:const Symbol 会推断为 unique symbol,因此 z.infer 会将该键推断为必需键,并检查其值类型。未声明的 Symbol 键仍会被忽略。(#6448)
Bug 修复
以下修复都解决了 soundness 问题,因此依赖旧行为的 schema 现在可能会拒绝过去能够接受的输入。
⚠️ z.iso.datetime() 要求秒
RFC 3339 强制要求秒。z.iso.datetime() 和 z.iso.datetime({ offset: true }) 不再接受类似 2020-01-01T06:15Z 的分钟精度输入。local: true 仍然接受 2020-01-01T06:15,因为无限定的 datetime 无论如何都不属于 RFC 3339。(#6457)
要接受这两种形式,请联合两种精度:
⚠️ 字符串长度按 code point 计算
.min()、.max() 和 .length() 之前按 UTF-16 code unit 计数,因此 z.string().max(5) 会拒绝五个 emoji。现在它们按 Unicode code point 计数,这也是所有非 JS 消费者处理长度限制时采用的方式(Postgres、MySQL、Go、Python,以及 z.toJSONSchema() 生成的 maxLength)。对于 astral 输入,.max() 只会放宽限制;.min() 和 .length() 则会收紧限制。Grapheme 不变——一个 ZWJ 序列仍然包含多个 code point。(#6441)
关闭 #3355。
⚠️ Record 键和交集与 TypeScript 保持一致
Record 的键 schema 现在只约束与其匹配的键,就像 TypeScript 对待 index signature 的方式一样。将对象与 pattern-keyed record 求交集时,不再拒绝对象自身的键。(#6412)
另外,unrecognized_keys issue 不再中止产生它的 schema,因此带有额外键和错误值的严格对象现在会报告两个 issue,而不只是第一个。关闭 #2200、#2573、#4017、#5663。
⚠️ __proto__ 始终会被移除
对象和 record parser 现在会丢弃 __proto__ 键,无论它来自输入、由 schema 声明,还是由 record key transform 生成。被 record 的 key schema 规范化为 __proto__ 的键也会被丢弃。.strict() 会将自有的 __proto__ 输入键报告为 unrecognized_keys,而不是静默吞掉它。错误格式化器和两个 JSON Schema 转换器都会使用 own-property 写入,因此 toString 或 constructor 路径片段无法遍历到 Object.prototype(#6213、#6367、#6346)。(#6386、#6354、#6355、#6221)
⚠️ 更严格的字符串格式
z.ipv6()之前通过将字符串传递给new URL()进行验证,这会让::@1\和::1\n通过。现在它会直接检查地址字符集(#6442)。z.ulid()将第一个字符限制为0–7;任何更大的值都会导致 48 位时间戳溢出。现在,不以真实时间戳开头的 fixture(例如以字母开头的 fixture)会被拒绝(#6095)。z.httpUrl()强制执行 RFC 1035 对 host 的长度限制,与z.hostname()保持一致(#6035)。z.emoji()在匹配失败时不再发生指数级回溯(#6347)。z.string().includes(sub, { position: N })会生成一个允许至少 N 个前导字符的 JSON Schema pattern,与String.prototype.includes保持一致(#6024)。
Commits
Zod 4.5 汇总了 155 个 commit。感谢所有贡献者:[@dokson](https://github.com/dokson)、[[@deepshekhardas](https://github.com/deepshekhardas)](https://github.com/deepshekhardas)、[[@zirkelc](https://github.com/zirkelc)](https://github.com/zirkelc)、[[@francisjohnjohnston-web](https://github.com/francisjohnjohnston-web)](https://github.com/francisjohnjohnston-web)、[[@MerlijnW70](https://github.com/MerlijnW70)](https://github.com/MerlijnW70)、[[@codinsonn](https://github.com/codinsonn)](https://github.com/codinsonn)、[[@oimo23](https://github.com/oimo23)](https://github.com/oimo23)、[[@JSap0914](https://github.com/JSap0914)](https://github.com/JSap0914)、[[@zelinewang](https://github.com/zelinewang)](https://github.com/zelinewang)、[[@abhishek-chaudhary2003](https://github.com/abhishek-chaudhary2003)](https://github.com/abhishek-chaudhary2003)、[[@spokodev](https://github.com/spokodev)](https://github.com/spokodev)、[[@Mohammad-Faiz-Cloud-Engineer](https://github.com/Mohammad-Faiz-Cloud-Engineer)](https://github.com/Mohammad-Faiz-Cloud-Engineer)、[[@hamed-bavar](https://github.com/hamed-bavar)](https://github.com/hamed-bavar)、[[@MGPOCKY](https://github.com/MGPOCKY)](https://github.com/MGPOCKY)、[[@ChiChuRita](https://github.com/ChiChuRita)](https://github.com/ChiChuRita)、[[@dinwwwh](https://github.com/dinwwwh)](https://github.com/dinwwwh)、[[@thristhart](https://github.com/thristhart)](https://github.com/thristhart)、[[@tsmartin9](https://github.com/tsmartin9)](https://github.com/tsmartin9)、[[@vedanshshetti](https://github.com/vedanshshetti)](https://github.com/vedanshshetti)、[[@belicam](https://github.com/belicam)](https://github.com/belicam)、[[@frastefanini](https://github.com/frastefanini)](https://github.com/frastefanini)、[[@andersk](https://github.com/andersk)](https://github.com/andersk)、[[@musaddiq-rafi](https://github.com/musaddiq-rafi)](https://github.com/musaddiq-rafi)、[[@tachmyratsaparmyradov](https://github.com/tachmyratsaparmyradov)](https://github.com/tachmyratsaparmyradov)、[[@arvindfroi](https://github.com/arvindfroi)](https://github.com/arvindfroi)、[[@KUMachine](https://github.com/KUMachine)](https://github.com/KUMachine)、[[@spidersouris](https://github.com/spidersouris)](https://github.com/spidersouris)、[[@catdalfonso](https://github.com/catdalfonso)](https://github.com/catdalfonso)、[[@mneetika](https://github.com/mneetika)](https://github.com/mneetika)、[[@gwagjiug](https://github.com/gwagjiug)](https://github.com/gwagjiug)、[[@MahinAnowar](https://github.com/MahinAnowar)](https://github.com/MahinAnowar)、[[@MaksZhukov](https://github.com/MaksZhukov)](https://github.com/MaksZhukov)、[[@emmayusufu](https://github.com/emmayusufu)](https://github.com/emmayusufu)、[[@agcty](https://github.com/agcty)](https://github.com/agcty)、[[@devareddy05](https://github.com/devareddy05)](https://github.com/devareddy05)、[[@Vish05](https://github.com/Vish05)](https://github.com/Vish05)、[[@yamcodes](https://github.com/yamcodes)](https://github.com/yamcodes)、[[@mattiasahlsen](https://github.com/mattiasahlsen)](https://github.com/mattiasahlsen)、[[@samchungy](https://github.com/samchungy)](https://github.com/samchungy)、[[@ozzyfromspace](https://github.com/ozzyfromspace)](https://github.com/ozzyfromspace)、[[@udohjeremiah](https://github.com/udohjeremiah)](https://github.com/udohjeremiah)、[[@patrickwehbe](https://github.com/patrickwehbe)](https://github.com/patrickwehbe)、[[@gajus](https://github.com/gajus)](https://github.com/gajus)、[[@Harm-Nullix](https://github.com/Harm-Nullix)](https://github.com/Harm-Nullix)、[[@thwbh](https://github.com/thwbh)](https://github.com/thwbh)、[[@IdanGonen](https://github.com/IdanGonen)](https://github.com/IdanGonen)、[[@irfanfandi](https://github.com/irfanfandi)](https://github.com/irfanfandi)、[[@JuerGenie](https://github.com/JuerGenie)](https://github.com/JuerGenie)、[[@marcalexiei](https://github.com/marcalexiei)](https://github.com/marcalexiei)、[[@itsahmedbilal](https://github.com/itsahmedbilal)](https://github.com/itsahmedbilal)、[[@DucMinhNe](https://github.com/DucMinhNe)](https://github.com/DucMinhNe)、[[@meliharik](https://github.com/meliharik)](https://github.com/meliharik)。
9782f87c性能(v4):在不构建输出的情况下进行验证,并使 schemas 脱离 dictionary 模式(#6480),作者: @colinhacks773a4867重构(v4):在 $constructor 上声明 trait 的成员(#6478),作者: @colinhacks68fb3f13功能(v4):让 z.compile() 回退而不是抛出异常(#6479),作者: @colinhacks37b01501功能(v4):添加 z.isValid 和 z.isValidAsync(#6471),作者: @colinhacks749f5452文档:将 fullproduct.dev 添加到 v4 生态页面(#6001),作者: @codinsonn24cdb7fd性能(v4):将 fastpass 绑定封装到已编译的解析器中(#6464),作者: @colinhacks8d896186修复(v4):停止生成会被 JSON Schema 拒绝的 multipleOf(#6468),作者: @colinhacks43f729db功能(v4):通过 .partial() 使 tuple 的 items 可选(#6465),作者: @colinhacks97edaf7d修复(v4):不要因 bigint multipleOf(0n) 从 safeParse 中抛出异常(#6466),作者: @colinhacks21a6f0cb功能(v4):让 z.nanoid() 接受自定义长度(#4004),作者: @oimo239d5b20ef修复(v4):将第一个 ULID 字符限制为 [0-7](#6095),作者: @JSap09141cf9cd09文档:记录 error maps 按每次解析运行,以及如何在渲染时进行翻译,作者: @colinhacks7ce3e77d修复(v4):让 wrapper 的内部 schema 在其自身 payload 上运行(#6462),作者: @colinhacks7b612b53修复(v4):将 object schemas 的交集合并为一个 object(#6461),作者: @colinhacks1c43b774文档(v4):记录为什么 failure path 不值得编译,作者: @colinhacksbadf0b78修复(v4):根据失败的 input 构建 catch context(#6192),作者: @zelinewanga87ac366修复(v4)!:在类型层面区分 number 和 bigint 格式(#6052),作者: @abhishek-chaudhary20036726c1dd文档:记录 z.input 和 z.output 如何处理 transforms 和 wrappers,作者: @colinhacks7cfc0122修复(v4):仅在所属的一侧保留 wrapper 存储的值,作者: @colinhacksa825c1b0修复(v4):空 enums 和 literals 不匹配任何内容(#6459),作者: @colinhacks7c070db9功能(v4):在 .implement() 结果上公开 function schema(#6267),作者: @deepshekhardas3a496968修复(v4):当 value 可以填充 record input keys 时,使其可选(#6460),作者: @colinhacks53cec2a0修复(v4):解析 preprocess transform 之后的 z.input,作者: @colinhacks2125d30c修复(v4):在 multipleOf 中接受精确的十进制倍数(#6223),作者: @spokodev168122fc修复(v4):通过 z.output 传递 pipe 自身的 checks,作者: @colinhacks51a1368a修复(v4):让 includes(position) 模式在 offset 处或之后进行匹配(#6024),作者: @francisjohnjohnston-web72a05c4f功能(v4):通过 _zod.bag 公开 stringbool 的 truthy/falsy/case(#6357),作者: @hamed-bavar036b39f4修复(v4)!:当 datetime 带有 Z 或 offset 时要求 seconds(#6457),作者: @colinhacks5825605e性能(v4):构建 ZodError 时跳过急切的堆栈捕获(#6450),作者: @colinhacksd85472c4功能(v4):支持 z.object() 中声明的 symbol keys(#6448),作者: @colinhacksd4108872修复(v4):修正两个 JSON Schema 方向中的 date/time format keywords(#6452),作者: @colinhacks555e5f46添加 z.toZod helper(#5913),作者: @colinhackse0e51a55文档(v4):将 compile 注释精简到其解释的内容(#6449),作者: @colinhacks6574e784修复(v4):停止 catch 重新激活 optional 已经解决的问题(#6440),作者: @colinhacks937b5d01性能(v4):在 object JIT failure path 中原地添加 issue paths 前缀(#6445),作者: @colinhacksb63db248修复(v4):将 memoized node 的 cached issues 保持为 cache 私有(#6443),作者: @colinhacks6ec3d043修复(resolution):将 pnpm 自身的 warnings 排除在 attw snapshot 之外(#6446),作者: @colinhacks830ba314修复(v4):验证 address,并返回已验证的字符串(#6442),作者: @colinhacksf101d8ca在 parse 堆栈跟踪中保留 callsites(#5910),作者: @colinhacks6c77d028功能:在 toJSONSchema 中将简单的 anyOf unions 压缩为 type array(#6339),作者: @deepshekhardas28e1ebd8修复(v4):以 Unicode code points 计算字符串长度(#6441),作者: @colinhacks060bc9f3重构:为 size/length checks 共享默认的 when-clauses(#6394),作者: @zirkelc2848177d文档:将 flattened/formatted error 弃用指向一个存在的 symbol,作者: @colinhacks3c2dee9e为 instanceof schemas 添加 properties checks(#5912),作者: @colinhacks87ffeb0f修复(v4):中间层级中缺失的 key 不提供任何内容(#6434),作者: @colinhacks7785fc82功能(v4):添加 z.getDiscriminatedOption(#5947),作者: @dokson0135c85a功能(v4):允许向 apply() 传递额外参数(#6337),作者: @deepshekhardasca246d26修复(v4):从 datetime pattern 中移除空的 alternation branch(#6439),作者: @colinhackse073d55b文档:z.iso.datetime() 接受 ISO 8601 的子集,而不是全部内容,作者: @colinhacksd6ca12ae修复(v4):在 discriminatedUnion 中推断递归 getter options(#6422),作者: @colinhacksdc51404b将 shorn 添加到 Zod Utilities(#6398),作者: @ChiChuRita580111da文档:标记 AOT compilation 仅供 canary 使用,作者: @colinhacks6b0dae79文档:说明 catch callback 不会被 islanded,作者: @colinhacks898c4461重构(v4):让 runtime 和 compiled code 使用一个 URL implementation,作者: @colinhacks260e5d4b修复(v4):停止 islanding catch callback,因为它会悄然产生偏差,作者: @colinhacks11c9268b回退(core):移除 #6432 中 exactOptional parse prototype(#6438),作者: @colinhacksa38ab4a8修复(core):可省略的 discriminator 声称 undefined(#6432),作者: @colinhacksc9ec89e0性能(core):从 lazy internals 中移除 seal 和每个 key 的 WeakSet(#6435),作者: @colinhacks3c9ca1d9功能(json-schema):当根 schema 有 id 时生成根 $ref(#6029),作者: @dinwwwhfa77a4d7功能(v4):z.compile — ahead-of-time schema compilation(#6085),作者: @colinhacksf300476d修复(v4):让 schema 的 error map 覆盖其自身 checks 产生的问题(#6426),作者: @colinhacks9f0a3d81修复(core):恢复 internals 移动时丢失的 defineLazy 语义(#6429),作者: @colinhacks604464c3修复(locales):da/nn/no/sv 将 IP address 称为 range(#6430),作者: @colinhacks7378e7cd修复(locales):补充 mac 和 Sizable.map 的缺失项,并固定 dictionary parity(#6427),作者: @colinhacksb1077f05性能(memory):在每个 constructor prototype 上安装 derived internals(#6415),作者: @colinhacksccc15144修复(locales):为缺少 credit_card key 的七个 locales 添加该 key(#6424),作者: @colinhacks73bacbbb修复(from-json-schema):移除 draft-04 exclusive ranges 中多余的 inclusive bound(#6022),作者: @francisjohnjohnston-web86b2e6da文档:在支持的 locales 中列出 el 和 hr,作者: @colinhacks45fdeda5修复(v4):将 refine optin 细化为三级阶梯,弃用 fallback payload flag(#6419),作者: @colinhacks5b34c0ce改进 Portuguese localization 并添加 Brazilian Portuguese(pt-BR)(#6076),作者: @thristhartdc1a40a5修复(locales):改进 French translation(#6120),作者: @tsmartin90175a043功能(locales):添加 Hindi 和 Kannada locale 支持(#6315),作者: @vedanshshetti536ee3b0Locales:添加 Slovak(sk)语言(#6041),作者: @belicam07b0c3d8修复:保留显式的 superRefine issue input(#6053),作者: @frastefaniniba98071c功能:向 ZodObject 添加 .exactPartial()(#6065),作者: @andersk234c407d功能(lang):添加 Bengali locale(#5974),作者: @musaddiq-rafi377cd9d7功能(locales):添加 turkmen(tk)locale(#6168),作者: @tachmyratsaparmyradov69b6bb08功能(locales):添加 Norwegian Nynorsk(nn)locale(#6092),作者: @arvindfroi33d82e6b添加 Central Kurdish(ckb)locale(#6078),作者: @KUMachine06666fe2修复(fr):移除“non-optionnel”中的连字符(#5999),作者: @spidersouris79cfedea功能(v4):在 check-originated issues 上公开所属 schema(#6420),作者: @colinhacks436b5da8文档:提出 compiled constructor graph,作者: @colinhackseb4682c9修复(json-schema):在 input mode 中解析 transform 和 catch 之后的 tuple minItems(#6418),作者: @colinhacks4d6b5cd3修复(json-schema):通过unrepresentable处理无法表示的默认值,作者: @colinhacks2abc9e05文档:说明 JSON Schema emitter 会读取 static optin(#6417),作者: @colinhacks578e1cd0功能(v4):在 fromJSONSchema 中支持 format: “hostname”(#6305),作者: @catdalfonso942bf8cb功能(v4):解析包含 reference cycles 的 input(#6387),作者: @colinhacks78b523f0修复(json-schema):在 input mode 中保持 preprocess object properties 为 required(#6133),作者: @MerlijnW70973b1b44修复(v4):从 input JSON Schema 中移除 output-typed catch values(#6409),作者: @colinhacks5e608851功能(v4):添加 z.deepPartial 和 runtime z.input / z.output(#5928),作者: @dokson4e1720c8修复(v4):使 record keys 和 intersection strictness 与 TypeScript 保持一致(#6412),作者: @colinhacks4cc4053d修复:遵循 closed record key schemas 的 loose mode(#6157),作者: @pullfrog[bot]69be843f修复(v4):阻止 object JIT fastpass 保留被吞掉的 issue 的 value(#6407),作者: @colinhacksb899cd17性能(json-schema):使 toJSONSchema(registry) 的复杂度与 registry 大小呈线性关系(#6408),作者: @colinhacks6074828e修复(v4):使 fromJSONSchema 的 propertyNames 与其他 object keywords 组合(#6411),作者: @colinhacksd7b209f3文档:将 Web URLs callout 指向 z.httpUrl()(#6410),作者: @colinhacks611bd762修复(mini):让 merge() 接受 object schema,与 classic 保持一致(#6404),作者: @colinhacksb53e53cc修复(v4):在 English locale 的 too_small/too_big messages 中使用 exact flag(#6177),作者: @pullfrog[bot]421cc9a5修复(json-schema):解析 $ref 时取消 JSON Pointer tokens 的转义(#6402),作者: @colinhacks4c27fe87修复(v4):让 z.xor() 在多个 options 匹配时给出独立的错误(#6376),作者: @colinhacksa106fbe7修复(v4):默认让 fromJSONSchema tuples 为 open-ended(#6020),作者: @mneetikae8034eba修复(v4):让 fromJSONSchema 中的 prefixItems/draft-7 items 遵循 minItems(#6201),作者: @pullfrog[bot]784e5c26修复(v4):让 bundlers 将 locales 从 default import 中 tree-shake 掉(#6384),作者: @colinhacks97edd70a修复(toJSONSchema):约束 closed tuple length(#6194),作者: @pullfrog[bot]f150020d修复(v4):转义 template literal patterns 中的非字符串 enum values(#5934),作者: @gwagjiugfaf33a28修复:显示重新导出的 compat aliases 上的 @deprecated(#6072),作者: @MahinAnowar3956224a文档:说明 metadata 优先于生成的 JSON Schema keywords(#6401),作者: @colinhacksa1904fc2修复(v4):报告 numeric min/max bounds 的 date origin(#6129),作者: @MerlijnW70bd18314c修复:在 toJSONSchema $ref 中转义 JSON Pointer 保留字符(关闭 #6027)(#6144),作者: @MaksZhukov2a5164f5修复(v4):在 regexes.domain 中强制执行 RFC 1035 length limits(#6035),作者: @emmayusufu0e5bc4b1修复(v4):在 fromJSONSchema 中遵循 additionalProperties:false 与 patternProperties 的组合(#6199),作者: @pullfrog[bot]c8f06d36修复(v4):澄清 infinite number errors(#5906),作者: @colinhacks9a7ecc35修复(json-schema):在 date-time format 中接受 RFC 3339 numeric offsets(#6298),作者: @agcty0a76f3d7功能(v4):添加 z.creditCard() string format(#5931),作者: @doksonbd6619c0功能(json-schema):接受unrepresentable函数(#6380),作者: @colinhacks9d20fdc3修复(v4):保留 z.preprocess input narrowing(#5967),作者: @devareddy053063993a性能(v4):通过将 methods 移至 prototype,使每个 schema 的内存占用降低约 90%(#6318),作者: @zirkelcfd074106功能(json-schema):在 unrepresentable error 之前运行override(#6391),作者: @colinhacks2715c12e修复(v4):在 tree-shaken bundles 中保留默认 English locale(#5959),作者: @colinhacks81d9fc6c文档:将 zod-form-action 添加到生态系统(#6314),作者: @Vish05d86df5e0文档:将 ArkEnv 添加到生态页面(#6203),作者: @yamcodes18b4ff99文档(ecosystem):将 zodql 添加到 API Libraries(#6227),作者: @mattiasahlsen479d6f51推广 oxlint(#6196),作者: @samchungy85dba7e1文档:记录 any/unknown object keys 为 required(#6388),作者: @colinhacksd24fb4c3修复:一致地从 parsed objects 中移除 proto(#6386),作者: @colinhacks7708d447性能(v4):延迟构建 ZodError(#6316),作者: @zirkelc8ac9ae51修复(docs-v3):在 Vercel 上提供 docsify SPA fallback(#6378),作者: @colinhacks31384464修复(v4):完成 reserved-key hardening(#6371),作者: @colinhacks600c6909文档:将 Attaform 添加到生态系统(#6188),作者: @ozzyfromspace37c05fa5文档(ecosystem):将 zod-to-mongo-schema 重命名为 zod-mongo-schema(#6178),作者: @udohjeremiahbadfdf08文档:将 keyof() ZodEnum type 更新为 v4 形式(#6124),作者: @patrickwehbee25b68e1性能(v4):让三个无用声明在 esbuild 下进行 tree-shake(#6381),作者: @colinhacks53397351文档(ecosystem):在 Zod To X 中添加 zod-mongoose 列表项(#6062),作者: @Harm-Nullixdfa0deb1文档: 将 tauri-typegen 添加到生态系统(#6032)由 @thwbh9c914ee8docs:为 refine() 添加动态错误消息和组合 refinement 示例(#6002)由 @IdanGonen921649defix(v4):formatError 和 treeifyError 处理继承名称的路径元素(#6367)由 @deepshekhardase7029aa4fix(v4):在 .strict() 下报告自有的 proto 键(#6221)由 @pullfrog[bot]9c540db8fix(v4):在键 schema 执行后重新检查 record 键(#6355)由 @colinhacks8bb89ea4docs:在 Strings、Arrays、Sets 和 Maps 部分添加 .nonempty()(#6056)由 @pullfrog[bot]599c0e41docs(ecosystem):添加@chrock-studio/overload和@chrock-studio/zod-utils(#6040)由 @JuerGenie27a9036adocs(ecosystem):eslint-plugin-zod现在是eslint-zod(#5975)由 @marcalexieie177a0eedocs(v4):记录 coerce 缺失键的破坏性变更(#5957)(#5964)由 @dokson66fba964docs:展示 z.instanceof 与内置类的用法(#6059)由 @itsahmedbilal2d90846afix(docs):使 prefault 示例可运行(#6063)由 @DucMinhNeead9fcb3fix(v4):将声明的 proto 键写入为自有属性(#6354)由 @colinhacksc58764c5docs:修复 v4 介绍中的 UUID helper 列表(#6214)由 @meliharikf238fbd2fix:从 emoji 正则表达式中移除指数级回溯(#6347)由 @colinhackse6c213ecfix(json-schema):在 schema 转换中将 proto 键保留为自有属性(#6346)由 @colinhacks573fcb75fix(errors):在每个错误树遍历器中使用自有属性语义(#6213)由 @pullfrog[bot]6f5e99fdfix(docs-v3):将 README.md 重命名为 home.md,以便 Vercel 提供服务由 @colinhacksbbc68f99docs:将 Zod 3 EOL 提示调整为信息性语气由 @colinhacks3fc9b25fdocs:将 library-authors 页面重新定位为 Zod-4-first;注明 Zod 3 EOL 由 @colinhacksf29f2a6dfix(v4):使 cidrv6 JSON schema pattern 与运行时匹配(#5945)由 @doksondfd8766bfix(v4):打破 classic schemas 与 iso 之间的循环导入(#5275)(#5926)由 @doksonfbe8ad1bfix(v4):允许在unrepresentable: "any"下使用动态.catch()(#5273)(#5925)由 @dokson