news.volyx.in

Zod 4 (zod.dev)

782 points by bpierre · 438 days ago · 255 comments on HN

Article summary

Zod 4 is a new version of the Zod schema validation library, which provides faster, more efficient, and more feature-rich validation for JavaScript applications. It includes improvements such as 14x faster string parsing, 7x faster array parsing, and a 100x reduction in TypeScript instantiations. Zod 4 also introduces a new system for adding metadata to schemas and supports recursive object types. A new variant, Zod Mini, is also introduced, which provides a functional, tree-shakable API for smaller bundle sizes. Zod 4 is designed to be a more efficient and scalable solution for schema validation, with a focus on performance, simplicity, and ease of use.

Main themes

  • Zod 4 features and improvements
  • schema validation libraries
  • TypeScript and runtime validation
  • GraphQL and API design
  • web development complexity
  • end-to-end type safety
  • validation and data shapes
  • API evolution and maintenance

What commenters say

  • Some developers prefer Zod over other schema validation libraries due to its ease of use and performance.
  • Others argue that Zod is not necessary and that GraphQL or other solutions can provide similar functionality.
  • The need for explicit validation is seen as a failure of modern web development, which requires multiple ways of describing the same data shapes.
  • Developers are looking for a single source of truth for schema validation that can be used across different languages and platforms.
  • Some argue that TypeScript should be able to export useful type data for runtime validation, rather than relying on separate libraries.
  • Others disagree, arguing that TypeScript should remain a static checking system and that runtime validation is a separate concern.
  • The use of Zod and other validation libraries is seen as a necessary evil in the current state of web development, where APIs are constantly evolving and data shapes are complex.
  • Some developers are using Zod in combination with other libraries and frameworks to achieve end-to-end type safety and validation.