Skip to content

Releases: colinhacks/zod

v4.0.0-beta

10 Apr 22:06
Compare
Choose a tag to compare
v4.0.0-beta Pre-release
Pre-release

Zod 4 is now in beta.

The repo now contains three separate packages:

  • zod
  • @zod/mini: a tree-shakable variant of Zod.
  • @zod/core: a library that implements logic/parsers shared between zod and @zod/mini.

During the beta period:

  • zod — published continuously to zod@next , e.g. [email protected]
  • @zod/mini — published continuously to @zod/mini@next , e.g. @zod/[email protected]
  • @zod/core — published to latest in the v.0x version range (initial development in semver)

To install/upgrade:

npm upgrade zod@next
npm install @zod/mini@next
npm install @zod/core

A note on versioning

For simplicity, additional beta will be continuously released as additional commits are made to the v4 branch.

After the beta:

  • stable versions of zod and @zod/mini will be released as 4.0.0. They will remain version-locked moving forward. They will be pinned to a specific @zod/core version.
  • @zod/core will be released as 1.0.0. It will not be version-locked to zod and @zod/mini. This gives those libraries the freedom to evolve their APIs independent of @zod/core. Moreover, @zod/core will likely serve as the underpinning for additional libraries in the future, so it may implement/modify code that isn't used by either zod or @zod/mini.

v3.24.2

11 Feb 22:53
Compare
Choose a tag to compare

Notes

Support asynchronous checks in z.custom() .

const customSchema = z.custom<number>(async (x) => {
  return typeof x === "number";
});

Commits:

v3.24.1

11 Dec 01:40
Compare
Choose a tag to compare

Commits:

v3.24.0

10 Dec 06:59
Compare
Choose a tag to compare

Implement @standard-schema/spec

This is the first version of Zod to implement the Standard Schema spec. This is a new community effort among several validation library authors to implement a common interface, with the goal of simplifying the process of integrating schema validators with the rest of the ecosystem. Read more about the project and goals here.

z.string().jwt()

Thanks to @Mokshit06 and @Cognition-Labs for this contribution!

To verify that a string is a valid 3-part JWT.

z.string().jwt();

⚠️ This does not verify your JWT cryptographically! It merely ensures its in the proper format. Use a library like jsonwebtoken to verify the JWT signature, parse the token, and read the claims.

To constrain the JWT to a specific algorithm:

z.string().jwt({ alg: "RS256" });

z.string().base64url()

Thank you to @marvinruder!

To complement the JWT validation, Zod 3.24 implements a standalone .base64url() string validation API. (The three elements of JWTs are base64url-encoded JSON strings.)

z.string().base64url()

This functionality is available along the standard z.string().base64() validator added in Zod 3.23.

z.string().cidr()

Thanks to @wataryooou for their work on this!

A validator for CIDR notation for specifying IP address ranges, e.g. 192.24.12.0/22.

z.string().cidr()

To specify an IP version:

z.string().cidr({ version: "v4" })
z.string().cidr({ version: "v6" })

View the full diff from 3.23.8: v3.23.8...v3.24.0

v3.23.8

08 May 19:13
Compare
Choose a tag to compare

Commits:

v3.23.7

07 May 20:00
Compare
Choose a tag to compare

Commits:

v3.23.6

03 May 00:59
Compare
Choose a tag to compare

Commits:

v3.23.5

29 Apr 19:41
Compare
Choose a tag to compare

Commits:

v3.23.4

23 Apr 17:35
Compare
Choose a tag to compare

Commits:

v3.23.3

22 Apr 22:49
Compare
Choose a tag to compare

Commits: