Change8

v4.5.0

📦 zodView on GitHub →
7 features🔧 7 symbols

Summary

Zod 4.5 introduces `z.compile()` for significant parsing performance improvements and adds new validators like `z.creditCard()` and `z.properties()`. It also includes a fast-path validation function `z.validate()` and reduces memory footprint.

Migration Steps

  1. To enable automatic compilation of all schemas, import `"zod/compile"` at the top of your entry point before any schemas are defined.
  2. Alternatively, use the Node.js CLI flag `--import zod/compile`.
  3. For Bun users, set `"preload": ["zod/compile"]` in `bunfig.toml`.
  4. For Nub users, set `"preload": ["zod/compile"]` in `nub.jsonc`.

✨ New Features

  • Introduced `z.compile()` for dramatically faster parsing performance by pre-compiling schemas into optimized JavaScript snippets.
  • Added `z.creditCard()` for validating credit card numbers (12-19 digits, optional separators, Luhn checksum).
  • Introduced `z.properties()` as a multi-property counterpart to `z.property()` for more complex object validation.
  • Added `z.deepPartial()` and `.exactPartial()` for creating schemas that are partially optional.
  • Introduced `z.validate(): boolean` for a fast-path to verify input validity without a full parse, up to 16x faster on invalid data.
  • Achieved a 9x reduction in schema memory footprint.
  • Added new locales for error customization: Bengali (bn), Central Kurdish (ckb), Hindi (hi), Kannada (kn), Norwegian Nynorsk (nn), Brazilian Portuguese (pt-BR), Slovak (sk), Turkmen (tk).

Affected Symbols