chore(deps): update dependency zod to v4 #7

Merged
apunkt merged 1 commit from renovate/zod-4.x into main 2026-05-22 10:54:54 +02:00
Collaborator

This PR contains the following updates:

Package Type Update Change
zod (source) dependencies major ^3.23.0^4.0.0

Release Notes

colinhacks/zod (zod)

v4.4.3

Compare Source

Commits:

  • 4c2fa95 docs: use Zernio primary wordmark for gold sponsor logo
  • 2aeec83 docs: prune lapsed gold sponsors and rebalance logo sizing
  • 7391be8 docs: prune lapsed silver/bronze sponsors and add active ones
  • 2c70332 docs: normalize bronze sponsor logos to github avatar pattern
  • 9195250 docs: remove Mintlify from bronze sponsors (churned)
  • b8dffe9 docs: remove Numeric and Speakeasy (2+ missed monthly cycles)
  • 1cab693 fix(v4): restore catch handling for absent object keys (#​5937) (#​5939)
  • c2be4f8 fix(v4): generalize optin/fallback to transform; restore preprocess on absent keys (#​5941)
  • f3c9ec0 4.4.3
  • 1fb56a5 docs: document release procedure in AGENTS.md

v4.4.2

Compare Source

Commits:

  • 0c62df0 Clean up docs navigation and stale labels (#​5901)
  • 20cc794 chore: add security policy and refresh tooling deps
  • 6fbe07b fix(docs): heading anchor links now include the hash so it doesnt scoll all the way up, follows navbar logic (#​5791)
  • 4bbed1b Tighten discriminated union option typing
  • bbac3e5 Update PR guidance for agents
  • cf0dc94 Merge remote-tracking branch 'origin/main' into fix-discriminated-union-key-constraint
  • 292c894 docs: add Zernio gold sponsor
  • 1fc9f31 docs: document codec inversion
  • 1373c85 docs: remove AI disclosure guidance
  • e20d02b chore: ignore triage notes
  • e58ea4d docs: test Zod Mini tab code heights
  • 905761a docs: document preprocess input type narrowing
  • bf64bac chore: tighten test guidance in AGENTS.md
  • 8ec4e73 chore: update play.ts scratch
  • 02c2baf Make z.preprocess defer optionality to inner schema (#​5929)
  • 88015df fix(docs): drop deprecated baseUrl from tsconfig
  • c59d447 4.4.2

v4.4.1

Compare Source

Commits:

  • 481f7be ci: gate release publishing on full test workflow
  • 95ccab4 test(v3): restore optional undefined expectations
  • cede2c6 fix(v4): reject tuple holes before required defaults (#​5900)
  • edd0bf0 release: 4.4.1
  • 180d83d docs: remove Jazz featured sponsor

v4.4.0

Compare Source

4.4.0

This is a minor release with a wide set of correctness and soundness fixes. Some fixes intentionally make Zod stricter, so code that depended on previously accepted invalid or ambiguous inputs may need small updates.

Potentially breaking bug fixes

Tuple defaults now materialize output values correctly

Fixed in #​5661. Tuple parsing now more accurately reflects defaults, optional tails, explicit undefined, and under-filled inputs. The headline behavior is that defaults in tuple positions now properly appear in parsed output.

const schema = z.tuple([
  z.string(),
  z.string().default("fallback"),
]);

schema.parse(["a"]);
// ["a", "fallback"]

Trailing optional elements that are absent still stay absent; they are not filled with undefined.

const schema = z.tuple([
  z.string(),
  z.string().optional(),
]);

schema.parse(["a"]);
// ["a"]

But explicit undefined values supplied by the caller are preserved.

schema.parse(["a", undefined]);
// ["a", undefined]

When optional elements appear before later defaults, the parsed tuple is now dense so array operations behave predictably.

const schema = z.tuple([
  z.string(),
  z.string().optional(),
  z.string().default("fallback"),
]);

schema.parse(["a"]);
// ["a", undefined, "fallback"]

Tuple length errors are also more consistent now. Since z.function() arguments are tuple-shaped, function input errors may look different.

Required object properties with z.undefined()

Fixed in #​5661, with follow-up coverage in 57d80a82. A property whose schema is z.undefined() is now treated as required. The key must be present, but its value may be undefined.

const schema = z.object({
  value: z.undefined(),
});

schema.safeParse({}).success;
// false

schema.safeParse({ value: undefined }).success;
// true

Use .optional() when the key itself may be absent.

const schema = z.object({
  value: z.undefined().optional(),
});

schema.safeParse({}).success;
// true

This also affects related .catch(), .partial(), .default(), and .prefault() combinations that previously relied on missing z.undefined() keys being treated as optional.

Safer .merge() behavior with refinements

Fixed in #​5856. The .merge() method now throws when the receiver has refinements, rather than silently producing ambiguous refinement behavior. Refinements from the second schema are preserved.

const a = z.object({ a: z.string() }).refine((val) => val.a.length > 0);
const b = z.object({ b: z.string() });

a.merge(b);
// throws

Prefer .extend() or .safeExtend() for object composition. The .merge() method is still supported for compatibility, but it is discouraged for new code because its semantics around overlapping keys and refinements are easier to misread.

JSON Schema $defs entries no longer include redundant id

Fixed in #​5759. JSON Schema conversion through z.toJSONSchema() now strips redundant id fields from $defs entries. This is required for correctness in older JSON Schema dialects from before $id was introduced: in those dialects, id changes the resolution scope, so leaving it inside an extracted definition can make references resolve incorrectly. The removed value was redundant because the schema had already been extracted into $defs, so the definition key itself is the identifier. This may affect consumers that were reading those internal id fields directly.

Other JSON Schema fixes in this release:

  • Draft-04/OpenAPI 3.0 min/max intersections: #​5700
  • Recursive lazy schemas with .describe(): #​5797
  • Falsy prefault values emitted as defaults: #​5893
  • CUID pattern output tightened: #​5880
String validators are stricter

Base64 validation now rejects whitespace instead of allowing atob()-style whitespace stripping. Fixed in #​5888.

z.base64().safeParse("Zm9v").success;
// true

z.base64().safeParse("Zm 9v").success;
// false

Other string validator changes:

  • CUID validation through z.cuid() has been tightened, and CUID v1 is now deprecated. Fixed in #​5880.
  • HTTP URL validation through z.httpUrl() now rejects malformed HTTP(S) URLs with a missing slash after the protocol. The underlying URL constructor normalizes inputs like https:/example.com, but Zod now rejects them instead of accepting the repaired URL. Fixed in #​5672, related to #​5284.
z.httpUrl().safeParse("https://example.com").success;
// true

z.httpUrl().safeParse("https:/example.com").success;
// false

z.httpUrl().safeParse("http:/www.apple.com").success;
// false
Union paths are fixed in formatted errors

Two union-related error fixes landed:

  • Nested union paths are now preserved correctly in the output of z.treeifyError() and z.formatError(). Fixed in #​5708 and 60ff3987.
  • Invalid discriminated union errors now include discriminator options and improved messages. Fixed in #​5723. This may affect users snapshotting ZodError output.

Other fixes

Record key transforms now run

Fixed in #​5891. Record schemas now run transforms on record keys.

const schema = z.record(
  z.string().transform((key) => key.toUpperCase()),
  z.number()
);

schema.parse({ foo: 1 });
// { FOO: 1 }

Related record fixes:

  • Key refinement failures now surface as structured invalid_key issues. Fixed in #​5719.
  • Non-enumerable properties are skipped more consistently. Fixed in #​5719.
  • The v3-style single-argument z.record(valueType) form works again. Fixed in 0e960108.
Metadata and input handling in fromJSONSchema()

Schema generation from JSON Schema now applies metadata more consistently across enum, const, not, anyOf, and multi-type schemas. Fixed in #​5758. It also rejects or normalizes more non-JSON-like inputs, including cyclic objects and BigInt. Fixed in 87cf0f93.

Codecs

Codec changes:

  • Encoding through z.discriminatedUnion().encode() now works when the discriminator uses a codec. Fixed in #​5769.
  • Codec inversion was added in #​5770.
const stringToNumber = z.codec(
  z.string(),
  z.number(),
  {
    decode: Number,
    encode: String,
  }
);

const numberToString = z.invertCodec(stringToNumber);
Transform context

Transform callbacks now support ctx.addIssue(). Fixed in #​5699.

Conditional .superRefine() with when

The when option was added for .superRefine(). Added in #​5741, with related abort behavior fixed in #​5681.

Defaults for Map and Set

Defaults for Map and Set are now cloned instead of shared across parses. Fixed in #​5855.

const schema = z.map(z.string(), z.number()).default(new Map());

const a = schema.parse(undefined);
const b = schema.parse(undefined);

a === b;
// false
Empty unions

Empty z.union([]), z.xor([]), and discriminated unions no longer crash at construction time. They construct and fail at parse time. Fixed in #​5869.

Floating-point multiples

Number multipleOf() / step() validation is more accurate for decimal and exponent edge cases. Fixed in #​5687 and #​5793.

Global config and jitless

Configuration fixes:

  • Global configuration is now shared through globalThis, improving behavior across mixed CJS/ESM module instances. Fixed in #​5889.
  • Jitless mode now avoids eval probing when set before first access. Fixed in #​5864.
Prototype pollution hardening

Object catchall paths now skip __proto__ keys. Fixed in #​5898.

Performance improvements

Reduced memory usage from lazy-bound methods

Fixed in #​5897. Classic builder methods are now lazy-bound through a shared internal prototype instead of eagerly attached per schema instance. This significantly reduces per-schema method allocation overhead, especially in codebases that construct many schemas. Detached methods continue to work:

const schema = z.string();
const optional = schema.optional;

optional.call(schema);
// still works
Improved tree-shaking

Implemented in 195e8696 and #​5689. Top-level factory calls are annotated as pure, and generated stub package manifests now include sideEffects: false. This gives bundlers more room to remove unused Zod code.

This is intended as the conclusive fix for a long-standing class of tree-shaking and bundle-size issues, especially in Next.js and Turbopack projects. The most visible symptom was that unused validators and locales could survive bundling even when importing from zod/mini or from a narrow subpath.

Related reports include:

{
  "sideEffects": false
}

Locales

Added or updated locale support:

Locale message text changed in some cases, which may affect snapshots.

Closed issues

The following issues were closed by PRs included in this release:

Commits

v4.3.6

Compare Source

Commits:

v4.3.5

Compare Source

Commits:

v4.3.4

Compare Source

Commits:

v4.3.3

Compare Source

Commits:

v4.3.2

Compare Source

Commits:

v4.3.1

Compare Source

Commits:

  • 0fe8840 allow non-overwriting extends with refinements. 4.3.1

v4.3.0

Compare Source

This is Zod's biggest release since 4.0. It addresses several of Zod's longest-standing feature requests.

z.fromJSONSchema()

Convert JSON Schema to Zod (#​5534, #​5586)

You can now convert JSON Schema definitions directly into Zod schemas. This function supports JSON Schema "draft-2020-12", "draft-7", "draft-4", and OpenAPI 3.0.

import * as z from "zod";

const schema = z.fromJSONSchema({
  type: "object",
  properties: {
    name: { type: "string", minLength: 1 },
    age: { type: "integer", minimum: 0 },
  },
  required: ["name"],
});

schema.parse({ name: "Alice", age: 30 }); // ✅

The API should be considered experimental. There are no guarantees of 1:1 "round-trip soundness": MySchema > z.toJSONSchema() > z.fromJSONSchema(). There are several features of Zod that don't exist in JSON Schema and vice versa, which makes this virtually impossible.

Features supported:

  • All primitive types (string, number, integer, boolean, null, object, array)
  • String formats (email, uri, uuid, date-time, date, time, ipv4, ipv6, and more)
  • Composition (anyOf, oneOf, allOf)
  • Object constraints (additionalProperties, patternProperties, propertyNames)
  • Array constraints (prefixItems, items, minItems, maxItems)
  • $ref for local references and circular schemas
  • Custom metadata is preserved

z.xor() — exclusive union (#​5534)

A new exclusive union type that requires exactly one option to match. Unlike z.union() which passes if any option matches, z.xor() fails if zero or more than one option matches.

const schema = z.xor([z.string(), z.number()]);

schema.parse("hello"); // ✅
schema.parse(42);      // ✅
schema.parse(true);    // ❌ zero matches

When converted to JSON Schema, z.xor() produces oneOf instead of anyOf.

z.looseRecord() — partial record validation (#​5534)

A new record variant that only validates keys matching the key schema, passing through non-matching keys unchanged. This is used to represent patternProperties in JSON Schema.

const schema = z.looseRecord(z.string().regex(/^S_/), z.string());

schema.parse({ S_name: "John", other: 123 });
// ✅ { S_name: "John", other: 123 }
// only S_name is validated, "other" passes through

.exactOptional() — strict optional properties (#​5589)

A new wrapper that makes a property key-optional (can be omitted) but does not accept undefined as an explicit value.

const schema = z.object({
  a: z.string().optional(),      // accepts `undefined`
  b: z.string().exactOptional(), // does not accept `undefined`
});

schema.parse({});                  // ✅
schema.parse({ a: undefined });    // ✅
schema.parse({ b: undefined });    // ❌

This makes it possible to accurately represent the full spectrum of optionality expressible using exactOptionalPropertyTypes.

.apply()

A utility method for applying arbitrary transformations to a schema, enabling cleaner schema composition. (#​5463)

const setCommonChecks = <T extends z.ZodNumber>(schema: T) => {
  return schema.min(0).max(100);
};

const schema = z.number().apply(setCommonChecks).nullable();

.brand() cardinality

The .brand() method now accepts a second argument to control whether the brand applies to input, output, or both. Closes #​4764, #​4836.

// output only (default)
z.string().brand<"UserId">();           // output is branded (default)
z.string().brand<"UserId", "out">();    // output is branded
z.string().brand<"UserId", "in">();     // input is branded
z.string().brand<"UserId", "inout">();  // both are branded

Type predicates on .refine() (#​5575)

The .refine() method now supports type predicates to narrow the output type:

const schema = z.string().refine((s): s is "a" => s === "a");

type Input = z.input<typeof schema>;   // string
type Output = z.output<typeof schema>; // "a"

ZodMap methods: min, max, nonempty, size (#​5316)

ZodMap now has parity with ZodSet and ZodArray:

const schema = z.map(z.string(), z.number())
  .min(1)
  .max(10)
  .nonempty();

schema.size; // access the size constraint

.with() alias for .check() (359c0db)

A new .with() method has been added as a more readable alias for .check(). Over time, more APIs have been added that don't qualify as "checks". The new method provides a readable alternative that doesn't muddy semantics.

z.string().with(
  z.minLength(5),
  z.toLowerCase()
);

// equivalent to:
z.string().check(
  z.minLength(5),
  z.trim(),
  z.toLowerCase()
);

z.slugify() transform

Transform strings into URL-friendly slugs. Works great with .with():

// Zod
z.string().slugify().parse("Hello World");           // "hello-world"

// Zod Mini
// using .with() for explicit check composition
z.string().with(z.slugify()).parse("Hello World");   // "hello-world"

z.meta() and z.describe() in Zod Mini (947b4eb)

Zod Mini now exports z.meta() and z.describe() as top-level functions for adding metadata to schemas:

import * as z from "zod/mini";

// add description
const schema = z.string().with(
  z.describe("A user's name"),
);

// add arbitrary metadata
const schema2 = z.number().with(
  z.meta({ deprecated: true })
);

More ergonomic intersections #​5587

When intersecting schemas that include z.strictObject(), Zod 4 now only rejects keys that are unrecognized by both sides of the intersection. Previously, any unrecognized key from either side would cause an error.

This means keys that are recognized by at least one side of the intersection will now pass validation:

const A = z.strictObject({ a: z.string() });
const B = z.object({ b: z.string() });

const C = z.intersection(A, B);

// Keys recognized by either side now work
C.parse({ a: "foo", b: "bar" }); // ✅ { a: "foo", b: "bar" }

// Extra keys are stripped (follows strip behavior from B)
C.parse({ a: "foo", b: "bar", c: "extra" }); // ✅ { a: "foo", b: "bar" }

When both sides are strict, only keys unrecognized by both sides will error:

const A = z.strictObject({ a: z.string() });
const B = z.strictObject({ b: z.string() });

const C = z.intersection(A, B);

// Keys recognized by either side work
C.parse({ a: "foo", b: "bar" }); // ✅

// Keys unrecognized by BOTH sides error
C.parse({ a: "foo", b: "bar", c: "extra" }); 
// ❌ ZodError: Unrecognized key: "c"

New locales

import * as z from "zod";
import { uz } from "zod/locales";

z.config(uz());




Bug fixes

All of these changes fix soundness issues in Zod. As with any bug fix there's some chance of breakage if you were intentionally or unintentionally relying on this unsound behavior.

⚠️ .pick() and .omit() disallowed on object schemas containing refinements (#​5317)

Using .pick() or .omit() on object schemas with refinements now throws an error. Previously, this would silently drop the refinements, leading to unexpected behavior.

const schema = z.object({
  password: z.string(),
  confirmPassword: z.string(),
}).refine(data => data.password === data.confirmPassword);

schema.pick({ password: true });
// 4.2: refinement silently dropped ⚠️
// 4.3: throws error ❌

Migration: The easiest way to migrate is to create a new schema using the shape of the old one.

const newSchema = z.object(schema.shape).pick({ ... })
⚠️ overwriting properties with.extend() disallowed on object schemas with refinements (#​5317)

Similarly, .extend() will throws on schemas with refinements if you are overwriting existing properties.

const schema = z.object({ 
  a: z.string() 
}).refine(/* ... */);

schema.extend({ a: z.number() }); // 4.3: throws error ❌

Instead you can use .safeExtend(), which statically ensures that you aren't changing the type signature of any pre-existing properties.

const schema = z.object({ 
  a: z.string(),
}).refine(/* ... */);

schema.safeExtend({ 
  a: z.string().min(5).max(10) 
}); // ✅ allows overwrite, preserves refinement
⚠️ Stricter object masking methods (#​5581)

Object masking methods (.pick(), .omit()) now validate that the keys provided actually exist in the schema:

const schema = z.object({ a: z.string() });

// 4.3: throws error for unrecognized keys
schema.pick({ nonexistent: true });
// error: unrecognized key: "nonexistent"




Additional changes

  • Fixed JSON Schema generation for z.iso.time with minute precision (#​5557)
  • Fixed error details for tuples with extraneous elements (#​5555)
  • Fixed includes method params typing to accept string | $ZodCheckIncludesParams (#​5556)
  • Fixed numeric formats error messages to be inclusive (#​5485)
  • Fixed implementAsync inferred type to always be a promise (#​5476)
  • Tightened E.164 regex to require a non-zero leading digit and 7–15 digits total (#​5524)
  • Fixed Dutch (nl) error strings (#​5529)
  • Convert Date instances to numbers in minimum/maximum checks (#​5351)
  • Improved numeric keys handling in z.record() (#​5585)
  • Lazy initialization of ~standard schema property (#​5363)
  • Functions marked as @__NO_SIDE_EFFECTS__ for better tree-shaking (#​5475)
  • Improved metadata tracking across child-parent relationships (#​5578)
  • Improved locale translation approach (#​5584)
  • Dropped id uniqueness enforcement at registry level (#​5574)

v4.2.1

Compare Source

Commits:

v4.2.0

Compare Source

Features

Implement Standard JSON Schema

standard-schema/standard-schema#134

Implement z.fromJSONSchema()
const jsonSchema = {
  type: "object",
  properties: {
    name: { type: "string" },
    age: { type: "number" }
  },
  required: ["name"]
};

const schema = z.fromJSONSchema(jsonSchema);
Implement z.xor()
const schema = z.xor(
  z.object({ type: "user", name: z.string() }),
  z.object({ type: "admin", role: z.string() })
);
// Exactly one of the schemas must match
Implement z.looseRecord()
const schema = z.looseRecord(z.string(), z.number());
// Allows additional properties beyond those defined

Commits:

v4.1.13

Compare Source

Commits:

v4.1.12

Compare Source

Commits:

v4.1.11

Compare Source

Commits:

v4.1.10

Compare Source

Commits:

v4.1.9

Compare Source

Commits:

v4.1.8

Compare Source

Commits:

v4.1.7

Compare Source

Commits:

v4.1.6

Compare Source

v4.1.5

Compare Source

Commits:

v4.1.4

Compare Source

Commits:

  • 3291c61 fix(v4): toJSONSchema - wrong tuple with null output when targeting openapi-3.0 (#​5156)
  • 23f41c7 test(v4): toJSONSchema - use validateOpenAPI30Schema in all relevant scenarios (#​5163)
  • 0a09fd2 Update installation instructions
  • 4ea5fec 4.1.4

v4.1.3

Compare Source

Commits:

  • 98ff675 Drop stringToBoolean
  • a410616 Fix typo
  • 0cf4589 fix(v4): toJSONSchema - add missing oneOf inside items in tuple conversion (#​5146)
  • 8bf0c16 fix(v4): toJSONSchema tuple path handling for draft-7 with metadata IDs (#​5152)
  • 5c5fa90 fix(v4): toJSONSchema - wrong record output when targeting openapi-3.0 (#​5141)
  • 87b97cc docs(codecs): update example to use payloadSchema (#​5150)
  • 309f358 fix(v4): toJSONSchema - output numbers with exclusive range correctly when targeting openapi-3.0 (#​5139)
  • 1e71ca9 docs: fix refine fn to encode works properly (#​5148)
  • a85ec3c fix(docs): correct example to use LooseDog instead of Dog (#​5136)
  • 3e98274 4.1.3

v4.1.2

Compare Source

Commits:

v4.1.1

Compare Source

Commits:

v4.1.0

Compare Source

The first minor version since the introduction of Zod 4 back in May. This version contains a number of features that barely missed the cut for the 4.0 release. With Zod 4 stable and widely adopted, there's more time to resume feature development.

Codecs

This is the flagship feature of this release. Codecs are a new API & schema type that encapsulates a bi-directional transformation. It's a huge missing piece in Zod that's finally filled, and it unlocks some totally new ways to use Zod.

const stringToDate = z.codec(
  z.iso.datetime(),  // input schema: ISO date string
  z.date(),          // output schema: Date object
  {
    decode: (isoString) => new Date(isoString), 
    encode: (date) => date.toISOString(),
  }
);

New top-level functions are added for processing inputs in the forward direction ("decoding") and backward direction ("encoding").

stringToDate.decode("2025-08-21T20:59:45.500Z")
// => Date

stringToDate.encode(new Date())
// => "2025-08-21T20:59:45.500Z"

Note

 — For bundle size reasons, these new methods have not added to Zod Mini schemas. Instead, this functionality is available via equivalent top-level functions.

// equivalent at runtime
z.decode(stringToDate, "2024-01-15T10:30:00.000Z");
z.encode(stringToDate, new Date());
.parse() vs .decode()

Both .parse() and decode() process data in the "forward" direction. They behave identically at runtime.

stringToDate.parse("2025-08-21T20:59:45.500Z");
stringToDate.decode("2025-08-21T20:59:45.500Z");

There is an important difference however. While .parse() accepts any input, .decode() expects a strongly typed input. That is, it expects an input of type string, whereas .parse() accepts unknown.

stringToDate.parse(Symbol('not-a-string'));
// => fails at runtime, but no TypeScript error

stringToDate.decode(Symbol("not-a-string"));
//                     ^ ❌ Argument of type 'symbol' is not assignable to parameter of type 'Date'. ts(2345)

This is a highly requested feature unto itself:

Encoding

You can use any Zod schema with .encode(). The vast majority of Zod schemas are non-transforming (the input and output types are identical) so .decode() and .encode() behave identically. Only certain schema types change their behavior:

  • Codecs — runs from B->A and executes the encode transform during encoding
  • Pipes — these execute B->A instead of A->B
  • Defaults and prefaults — Only applied in the forward direction
  • Catch — Only applied in the forward direction

Note

— To avoid increasing bundle size unnecessarily, these new methods are not available on Zod Mini schemas. For those schemas, equivalent top-level functions are provided.

The usual async and safe variants exist as well:

// decode methods
stringToDate.decode("2024-01-15T10:30:00.000Z")
await stringToDate.decodeAsync("2024-01-15T10:30:00.000Z")
stringToDate.safeDecode("2024-01-15T10:30:00.000Z")
await stringToDate.safeDecodeAsync("2024-01-15T10:30:00.000Z")

// encode methods
stringToDate.encode(new Date())
await stringToDate.encodeAsync(new Date())
stringToDate.safeEncode(new Date())
await stringToDate.safeEncodeAsync(new Date())
Example codecs

Below are some "worked examples" for some commonly-needed codecs. These examples are all tested internally for correctness. Just copy/paste them into your project as needed. There is a more comprehensive set available at zod.dev/codecs.

stringToBigInt

Converts bigint into a serializable form.

const stringToBigInt = z.codec(z.string(), z.bigint(), {
  decode: (str) => BigInt(str),
  encode: (bigint) => bigint.toString(),
});

stringToBigInt.decode("12345");  // => 12345n
stringToBigInt.encode(12345n);   // => "12345"
json

Parses/stringifies JSON data.

const jsonCodec = z.codec(z.string(), z.json(), {
  decode: (jsonString, ctx) => {
    try {
      return JSON.parse(jsonString);
    } catch (err: any) {
      ctx.issues.push({
        code: "invalid_format",
        format: "json_string",
        input: jsonString,
        message: err.message,
      });
      return z.NEVER;
    }
  },
  encode: (value) => JSON.stringify(value),
});

To further validate the data, .pipe() the result of this codec into another schema.

const Params = z.object({ name: z.string(), age: z.number() });
const JsonToParams = jsonCodec.pipe(Params);

JsonToParams.decode('{"name":"Alice","age":30}');  // => { name: "Alice", age: 30 }
JsonToParams.encode({ name: "Bob", age: 25 });     // => '{"name":"Bob","age":25}'
Further reading

For more examples and a technical breakdown of how encoding works, reads theannouncement blog post and new Codecs docs page. The docs page contains implementations for several other commonly-needed codecs:

.safeExtend()

The existing way to add additional fields to an object is to use .extend().

const A = z.object({ a: z.string() })
const B = A.extend({ b: z.string() })

Unfortunately this is a bit of a misnomer, as it allows you to overwrite existing fields. This means the result of .extend() may not literally extend the original type (in the TypeScript sense).

const A = z.object({ a: z.string() }) // { a: string }
const B = A.extend({ a: z.number() }) // { a: number }

To enforce true extends logic, Zod 4.1 introduces a new .safeExtend() method. This statically enforces that the newly added properties conform to the existing ones.

z.object({ a: z.string() }).safeExtend({ a: z.number().min(5) }); // ✅
z.object({ a: z.string() }).safeExtend({ a: z.any() }); // ✅
z.object({ a: z.string() }).safeExtend({ a: z.number() });
//                                       ^  ❌ ZodNumber is not assignable 

Importantly, this new API allows you to safely extend objects containing refinements.

const AB = z.object({ a: z.string(), b: z.string() }).refine(val => val.a === val.b);
const ABC = AB.safeExtend({ c: z.string() });
// ABC includes the refinements defined on AB

Previously (in Zod 4.x) any refinements attached to the base schema were dropped in the extended result. This was too unexpected. It now throws an error. (Zod 3 did not support extension of refined objects either.)

z.hash()

A new top-level string format for validating hashes produced using various common algorithms & encodings.

const md5Schema = z.hash("md5");          
// => ZodCustomStringFormat<"md5_hex">

const sha256Base64 = z.hash("sha256", { enc: "base64" }); 
// => ZodCustomStringFormat<"sha256_base64">

The following hash algorithms and encodings are supported. Each cell provides information about the expected number of characters/padding.

Algorithm / Encoding "hex" "base64" "base64url"
"md5" 32 24 (22 + "==") 22
"sha1" 40 28 (27 + "=") 27
"sha256" 64 44 (43 + "=") 43
"sha384" 96 64 (no padding) 64
"sha512" 128 88 (86 + "==") 86

z.hex()

To validate hexadecimal strings of any length.

const hexSchema = z.hex();

hexSchema.parse("123abc");    // ✅ "123abc"
hexSchema.parse("DEADBEEF");  // ✅ "DEADBEEF" 
hexSchema.parse("xyz");       // ❌ ZodError

Additional changes

  1. z.uuid() now supports the "Max UUID" (FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF) per the RFC
  2. $ZodFunction is now a subtype of $ZodType

Commits

v4.0.17

Compare Source

Commits:

v4.0.16

Compare Source

Commits:

v4.0.15

Compare Source

Commits:

v4.0.14

Compare Source

Commits:

v4.0.13

Compare Source

Commits:

v4.0.12

Compare Source

Commits:

v4.0.11

Compare Source

Commits:

v4.0.10

Compare Source

Commits:

v4.0.9

Compare Source

Commits:

v4.0.8

Compare Source

Commits:

v4.0.7

Compare Source

Commits:

v4.0.6

Compare Source

Commits:

v4.0.5

Compare Source

Commits:

v4.0.4

Compare Source

Commits:

  • 9335f05 Adds ZodFirstPartyTypeKind stub to fix module resolution failure inside zod-to-json-schema

v4.0.3

Compare Source

Commits:

v4.0.2

Compare Source

v4.0.1: v4.0.0

Compare Source

With this release, zod@4.0.0 has been published to npm. There were no code changes between 3.25.76 and 4.0.0!

Zod 4 has been stable for the past 6 weeks, but it was published inside zod@3.25.x on npm. this transitionary window gave the ecosystem time to incrementally support for Zod 4 (without dropping support for Zod 3). As there is now near-universal support for Zod 4 in the ecosystem, ths time feels right to finally put a bow on things 🎀

To upgrade to Zod 4:

npm upgrade zod@^4.0.0

If you’ve already migrated to Zod 4 using the subpaths, there are no changes required. however you can optionally simplify your imports (recommended)

// after upgrading to zod@4.0.0:
import * as z from "zod"; // Zod 4 (regular)
import * as z from "zod/mini" // Zod 4 Mini

// these still work, but are no longer needed 
import * as z from "zod/v4"; 
import * as z from "zod/v4-mini":

// if you still need Zod 3
import * as z from "zod/v3"; // Zod 3

Library authors — if you've already implemented Zod 4 support according to the best practices outlined in the Library authors guide, bump your peer dependency to include zod@^4.0.0:

// package.json
{
  "peerDependencies": {
    "zod": "^3.25.0 || ^4.0.0"
  }
}

There should be no other code changes necessary. No code changes were made between the latest 3.25.x release and 4.0.0. This does not require a major version bump.

v4.0.0

Compare Source


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate.

This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [zod](https://zod.dev) ([source](https://github.com/colinhacks/zod)) | dependencies | major | [`^3.23.0` → `^4.0.0`](https://renovatebot.com/diffs/npm/zod/3.25.76/4.4.3) | --- ### Release Notes <details> <summary>colinhacks/zod (zod)</summary> ### [`v4.4.3`](https://github.com/colinhacks/zod/releases/tag/v4.4.3) [Compare Source](https://github.com/colinhacks/zod/compare/v4.4.2...v4.4.3) #### Commits: - [`4c2fa95`](https://github.com/colinhacks/zod/commit/4c2fa95ce3f3390fbc522324e406b4e9e89b88f9) docs: use Zernio primary wordmark for gold sponsor logo - [`2aeec83`](https://github.com/colinhacks/zod/commit/2aeec83eb135e3a83756e973ef44845fc5a455d2) docs: prune lapsed gold sponsors and rebalance logo sizing - [`7391be8`](https://github.com/colinhacks/zod/commit/7391be88ac1ee5cd02057f5ccc012a1f5df4efd0) docs: prune lapsed silver/bronze sponsors and add active ones - [`2c70332`](https://github.com/colinhacks/zod/commit/2c703322a21b4e2b12f33f49ea8430c451a68b4f) docs: normalize bronze sponsor logos to github avatar pattern - [`9195250`](https://github.com/colinhacks/zod/commit/9195250cab0e7950efe39c3926d6c203b4b0a170) docs: remove Mintlify from bronze sponsors (churned) - [`b8dffe9`](https://github.com/colinhacks/zod/commit/b8dffe9e62f17e6571e6249d05cc5102b54d94e4) docs: remove Numeric and Speakeasy (2+ missed monthly cycles) - [`1cab693`](https://github.com/colinhacks/zod/commit/1cab69383fcdeae2a366d5e2a2fc4d8fc765d168) fix(v4): restore catch handling for absent object keys ([#&#8203;5937](https://github.com/colinhacks/zod/issues/5937)) ([#&#8203;5939](https://github.com/colinhacks/zod/issues/5939)) - [`c2be4f8`](https://github.com/colinhacks/zod/commit/c2be4f819064eed62c7c350a2d399b5faecd15f8) fix(v4): generalize optin/fallback to transform; restore preprocess on absent keys ([#&#8203;5941](https://github.com/colinhacks/zod/issues/5941)) - [`f3c9ec0`](https://github.com/colinhacks/zod/commit/f3c9ec03ba7a28ae72d25cc295f38674bee0f559) 4.4.3 - [`1fb56a5`](https://github.com/colinhacks/zod/commit/1fb56a5c18c27102dbc92260a4007c7732a0ccca) docs: document release procedure in AGENTS.md ### [`v4.4.2`](https://github.com/colinhacks/zod/releases/tag/v4.4.2) [Compare Source](https://github.com/colinhacks/zod/compare/v4.4.1...v4.4.2) #### Commits: - [`0c62df0`](https://github.com/colinhacks/zod/commit/0c62df0ea19fd05abdf90473e9eef7eea530fab2) Clean up docs navigation and stale labels ([#&#8203;5901](https://github.com/colinhacks/zod/issues/5901)) - [`20cc794`](https://github.com/colinhacks/zod/commit/20cc794895cc8604fe0c87d83a5d1c3f89fad0ac) chore: add security policy and refresh tooling deps - [`6fbe07b`](https://github.com/colinhacks/zod/commit/6fbe07b0177efdd1bf1c0b05160e70d7a0702337) fix(docs): heading anchor links now include the hash so it doesnt scoll all the way up, follows navbar logic ([#&#8203;5791](https://github.com/colinhacks/zod/issues/5791)) - [`4bbed1b`](https://github.com/colinhacks/zod/commit/4bbed1b1c73eca4ce9e59b1189ed236aa6c8b5bd) Tighten discriminated union option typing - [`bbac3e5`](https://github.com/colinhacks/zod/commit/bbac3e567e7fccfaaf7cdc97f1ce30c295e2c908) Update PR guidance for agents - [`cf0dc94`](https://github.com/colinhacks/zod/commit/cf0dc942a32805c292fff59ade20a7ace980735a) Merge remote-tracking branch 'origin/main' into fix-discriminated-union-key-constraint - [`292c894`](https://github.com/colinhacks/zod/commit/292c894a5fd2aa42e527900b83d8d7a3009a709c) docs: add Zernio gold sponsor - [`1fc9f31`](https://github.com/colinhacks/zod/commit/1fc9f311c28dcf80d0bb5a36b177086cbc3d8eca) docs: document codec inversion - [`1373c85`](https://github.com/colinhacks/zod/commit/1373c85da9aeff704a9762d27bc58699618aefb7) docs: remove AI disclosure guidance - [`e20d02b`](https://github.com/colinhacks/zod/commit/e20d02b473c08e3a4e557bc610b1b5fac079b649) chore: ignore triage notes - [`e58ea4d`](https://github.com/colinhacks/zod/commit/e58ea4d91b1dfe8194b73508203213cbc7e9c936) docs: test Zod Mini tab code heights - [`905761a`](https://github.com/colinhacks/zod/commit/905761a5d127e8d5dd2ebb3bc88c75cb0b8149ff) docs: document preprocess input type narrowing - [`bf64bac`](https://github.com/colinhacks/zod/commit/bf64bac850d4dee2b7dde7e64909d5d796d32043) chore: tighten test guidance in AGENTS.md - [`8ec4e73`](https://github.com/colinhacks/zod/commit/8ec4e73f4c4693b6361ad591be40fb41eb8a9f95) chore: update play.ts scratch - [`02c2baf`](https://github.com/colinhacks/zod/commit/02c2baf7d0d615872fa4528a8020603b71211702) Make z.preprocess defer optionality to inner schema ([#&#8203;5929](https://github.com/colinhacks/zod/issues/5929)) - [`88015df`](https://github.com/colinhacks/zod/commit/88015df8e25c44fb5385eb3ef28935119cd5edea) fix(docs): drop deprecated `baseUrl` from tsconfig - [`c59d447`](https://github.com/colinhacks/zod/commit/c59d4474e3b4cad1b323462186cf607178ce8267) 4.4.2 ### [`v4.4.1`](https://github.com/colinhacks/zod/releases/tag/v4.4.1) [Compare Source](https://github.com/colinhacks/zod/compare/v4.4.0...v4.4.1) #### Commits: - [`481f7be`](https://github.com/colinhacks/zod/commit/481f7be4238c83ed58183f921b2646f340a91c6a) ci: gate release publishing on full test workflow - [`95ccab4`](https://github.com/colinhacks/zod/commit/95ccab423aec720b2523c3a64cdc7e3204537cc7) test(v3): restore optional undefined expectations - [`cede2c6`](https://github.com/colinhacks/zod/commit/cede2c63739a5823d6aa5093d291e9a111da943d) fix(v4): reject tuple holes before required defaults ([#&#8203;5900](https://github.com/colinhacks/zod/issues/5900)) - [`edd0bf0`](https://github.com/colinhacks/zod/commit/edd0bf0f5ada4a8dc581c259407d7bbad0a71ea7) release: 4.4.1 - [`180d83d`](https://github.com/colinhacks/zod/commit/180d83d1dbe6a59260710cc8637a3dea2281ee56) docs: remove Jazz featured sponsor ### [`v4.4.0`](https://github.com/colinhacks/zod/releases/tag/v4.4.0) [Compare Source](https://github.com/colinhacks/zod/compare/v4.3.6...v4.4.0) #### 4.4.0 This is a minor release with a wide set of correctness and soundness fixes. Some fixes intentionally make Zod stricter, so code that depended on previously accepted invalid or ambiguous inputs may need small updates. #### Potentially breaking bug fixes ##### Tuple defaults now materialize output values correctly Fixed in [#&#8203;5661](https://github.com/colinhacks/zod/pull/5661). Tuple parsing now more accurately reflects defaults, optional tails, explicit `undefined`, and under-filled inputs. The headline behavior is that defaults in tuple positions now properly appear in parsed output. ```ts const schema = z.tuple([ z.string(), z.string().default("fallback"), ]); schema.parse(["a"]); // ["a", "fallback"] ``` Trailing optional elements that are absent still stay absent; they are not filled with `undefined`. ```ts const schema = z.tuple([ z.string(), z.string().optional(), ]); schema.parse(["a"]); // ["a"] ``` But explicit `undefined` values supplied by the caller are preserved. ```ts schema.parse(["a", undefined]); // ["a", undefined] ``` When optional elements appear before later defaults, the parsed tuple is now dense so array operations behave predictably. ```ts const schema = z.tuple([ z.string(), z.string().optional(), z.string().default("fallback"), ]); schema.parse(["a"]); // ["a", undefined, "fallback"] ``` Tuple length errors are also more consistent now. Since `z.function()` arguments are tuple-shaped, function input errors may look different. ##### Required object properties with `z.undefined()` Fixed in [#&#8203;5661](https://github.com/colinhacks/zod/pull/5661), with follow-up coverage in [`57d80a82`](https://github.com/colinhacks/zod/commit/57d80a82bde8877f3eb79e5dad9786096c37490f). A property whose schema is `z.undefined()` is now treated as required. The key must be present, but its value may be `undefined`. ```ts const schema = z.object({ value: z.undefined(), }); schema.safeParse({}).success; // false schema.safeParse({ value: undefined }).success; // true ``` Use `.optional()` when the key itself may be absent. ```ts const schema = z.object({ value: z.undefined().optional(), }); schema.safeParse({}).success; // true ``` This also affects related `.catch()`, `.partial()`, `.default()`, and `.prefault()` combinations that previously relied on missing `z.undefined()` keys being treated as optional. ##### Safer `.merge()` behavior with refinements Fixed in [#&#8203;5856](https://github.com/colinhacks/zod/pull/5856). The `.merge()` method now throws when the receiver has refinements, rather than silently producing ambiguous refinement behavior. Refinements from the second schema are preserved. ```ts const a = z.object({ a: z.string() }).refine((val) => val.a.length > 0); const b = z.object({ b: z.string() }); a.merge(b); // throws ``` > Prefer `.extend()` or `.safeExtend()` for object composition. The `.merge()` method is still supported for compatibility, but it is discouraged for new code because its semantics around overlapping keys and refinements are easier to misread. ##### JSON Schema `$defs` entries no longer include redundant `id` Fixed in [#&#8203;5759](https://github.com/colinhacks/zod/pull/5759). JSON Schema conversion through `z.toJSONSchema()` now strips redundant `id` fields from `$defs` entries. This is required for correctness in older JSON Schema dialects from before `$id` was introduced: in those dialects, `id` changes the resolution scope, so leaving it inside an extracted definition can make references resolve incorrectly. The removed value was redundant because the schema had already been extracted into `$defs`, so the definition key itself is the identifier. This may affect consumers that were reading those internal `id` fields directly. Other JSON Schema fixes in this release: - Draft-04/OpenAPI 3.0 min/max intersections: [#&#8203;5700](https://github.com/colinhacks/zod/pull/5700) - Recursive lazy schemas with `.describe()`: [#&#8203;5797](https://github.com/colinhacks/zod/pull/5797) - Falsy prefault values emitted as defaults: [#&#8203;5893](https://github.com/colinhacks/zod/pull/5893) - CUID pattern output tightened: [#&#8203;5880](https://github.com/colinhacks/zod/pull/5880) ##### String validators are stricter Base64 validation now rejects whitespace instead of allowing `atob()`-style whitespace stripping. Fixed in [#&#8203;5888](https://github.com/colinhacks/zod/pull/5888). ```ts z.base64().safeParse("Zm9v").success; // true z.base64().safeParse("Zm 9v").success; // false ``` Other string validator changes: - CUID validation through `z.cuid()` has been tightened, and CUID v1 is now deprecated. Fixed in [#&#8203;5880](https://github.com/colinhacks/zod/pull/5880). - HTTP URL validation through `z.httpUrl()` now rejects malformed HTTP(S) URLs with a missing slash after the protocol. The underlying `URL` constructor normalizes inputs like `https:/example.com`, but Zod now rejects them instead of accepting the repaired URL. Fixed in [#&#8203;5672](https://github.com/colinhacks/zod/pull/5672), related to [#&#8203;5284](https://github.com/colinhacks/zod/issues/5284). ```ts z.httpUrl().safeParse("https://example.com").success; // true z.httpUrl().safeParse("https:/example.com").success; // false z.httpUrl().safeParse("http:/www.apple.com").success; // false ``` ##### Union paths are fixed in formatted errors Two union-related error fixes landed: - Nested union paths are now preserved correctly in the output of `z.treeifyError()` and `z.formatError()`. Fixed in [#&#8203;5708](https://github.com/colinhacks/zod/pull/5708) and [`60ff3987`](https://github.com/colinhacks/zod/commit/60ff398771bb4b6df04d96f00b9a10ee561ee7af). - Invalid discriminated union errors now include discriminator options and improved messages. Fixed in [#&#8203;5723](https://github.com/colinhacks/zod/pull/5723). This may affect users snapshotting `ZodError` output. #### Other fixes ##### Record key transforms now run Fixed in [#&#8203;5891](https://github.com/colinhacks/zod/pull/5891). Record schemas now run transforms on record keys. ```ts const schema = z.record( z.string().transform((key) => key.toUpperCase()), z.number() ); schema.parse({ foo: 1 }); // { FOO: 1 } ``` Related record fixes: - Key refinement failures now surface as structured `invalid_key` issues. Fixed in [#&#8203;5719](https://github.com/colinhacks/zod/pull/5719). - Non-enumerable properties are skipped more consistently. Fixed in [#&#8203;5719](https://github.com/colinhacks/zod/pull/5719). - The v3-style single-argument `z.record(valueType)` form works again. Fixed in [`0e960108`](https://github.com/colinhacks/zod/commit/0e960108f0d98dbea7844a8ff914f0980352f636). ##### Metadata and input handling in `fromJSONSchema()` Schema generation from JSON Schema now applies metadata more consistently across `enum`, `const`, `not`, `anyOf`, and multi-type schemas. Fixed in [#&#8203;5758](https://github.com/colinhacks/zod/pull/5758). It also rejects or normalizes more non-JSON-like inputs, including cyclic objects and `BigInt`. Fixed in [`87cf0f93`](https://github.com/colinhacks/zod/commit/87cf0f93cd0f34bdc69f11c9377568e6812841c4). ##### Codecs Codec changes: - Encoding through `z.discriminatedUnion().encode()` now works when the discriminator uses a codec. Fixed in [#&#8203;5769](https://github.com/colinhacks/zod/pull/5769). - Codec inversion was added in [#&#8203;5770](https://github.com/colinhacks/zod/pull/5770). ```ts const stringToNumber = z.codec( z.string(), z.number(), { decode: Number, encode: String, } ); const numberToString = z.invertCodec(stringToNumber); ``` ##### Transform context Transform callbacks now support `ctx.addIssue()`. Fixed in [#&#8203;5699](https://github.com/colinhacks/zod/pull/5699). ##### Conditional `.superRefine()` with `when` The `when` option was added for `.superRefine()`. Added in [#&#8203;5741](https://github.com/colinhacks/zod/pull/5741), with related abort behavior fixed in [#&#8203;5681](https://github.com/colinhacks/zod/pull/5681). ##### Defaults for `Map` and `Set` Defaults for `Map` and `Set` are now cloned instead of shared across parses. Fixed in [#&#8203;5855](https://github.com/colinhacks/zod/pull/5855). ```ts const schema = z.map(z.string(), z.number()).default(new Map()); const a = schema.parse(undefined); const b = schema.parse(undefined); a === b; // false ``` ##### Empty unions Empty `z.union([])`, `z.xor([])`, and discriminated unions no longer crash at construction time. They construct and fail at parse time. Fixed in [#&#8203;5869](https://github.com/colinhacks/zod/pull/5869). ##### Floating-point multiples Number `multipleOf()` / `step()` validation is more accurate for decimal and exponent edge cases. Fixed in [#&#8203;5687](https://github.com/colinhacks/zod/pull/5687) and [#&#8203;5793](https://github.com/colinhacks/zod/pull/5793). ##### Global config and `jitless` Configuration fixes: - Global configuration is now shared through `globalThis`, improving behavior across mixed CJS/ESM module instances. Fixed in [#&#8203;5889](https://github.com/colinhacks/zod/pull/5889). - Jitless mode now avoids eval probing when set before first access. Fixed in [#&#8203;5864](https://github.com/colinhacks/zod/pull/5864). ##### Prototype pollution hardening Object catchall paths now skip `__proto__` keys. Fixed in [#&#8203;5898](https://github.com/colinhacks/zod/pull/5898). #### Performance improvements ##### Reduced memory usage from lazy-bound methods Fixed in [#&#8203;5897](https://github.com/colinhacks/zod/pull/5897). Classic builder methods are now lazy-bound through a shared internal prototype instead of eagerly attached per schema instance. This significantly reduces per-schema method allocation overhead, especially in codebases that construct many schemas. Detached methods continue to work: ```ts const schema = z.string(); const optional = schema.optional; optional.call(schema); // still works ``` ##### Improved tree-shaking Implemented in [`195e8696`](https://github.com/colinhacks/zod/commit/195e86962b5156012a4cdcfbff87dffddce87b78) and [#&#8203;5689](https://github.com/colinhacks/zod/pull/5689). Top-level factory calls are annotated as pure, and generated stub package manifests now include `sideEffects: false`. This gives bundlers more room to remove unused Zod code. This is intended as the conclusive fix for a long-standing class of tree-shaking and bundle-size issues, especially in Next.js and Turbopack projects. The most visible symptom was that unused validators and locales could survive bundling even when importing from `zod/mini` or from a narrow subpath. Related reports include: - Next.js and Turbopack tree-shaking reports: [#&#8203;4433](https://github.com/colinhacks/zod/issues/4433), [#&#8203;5641](https://github.com/colinhacks/zod/issues/5641), [#&#8203;5095](https://github.com/colinhacks/zod/issues/5095), [#&#8203;4810](https://github.com/colinhacks/zod/issues/4810) - Locale and `zod/mini` bundle-size reports: [#&#8203;5561](https://github.com/colinhacks/zod/issues/5561), [#&#8203;5665](https://github.com/colinhacks/zod/issues/5665), [#&#8203;4369](https://github.com/colinhacks/zod/issues/4369), [#&#8203;4572](https://github.com/colinhacks/zod/issues/4572) - Broader v4 bundle-size reports: [#&#8203;2596](https://github.com/colinhacks/zod/issues/2596), [#&#8203;4637](https://github.com/colinhacks/zod/issues/4637), [#&#8203;4798](https://github.com/colinhacks/zod/issues/4798), [#&#8203;5206](https://github.com/colinhacks/zod/issues/5206) ```json { "sideEffects": false } ``` #### Locales Added or updated locale support: - Croatian: [#&#8203;5610](https://github.com/colinhacks/zod/pull/5610) - Greek: [#&#8203;5840](https://github.com/colinhacks/zod/pull/5840) - Romanian: [#&#8203;5657](https://github.com/colinhacks/zod/pull/5657) - Uzbek map support: [#&#8203;5599](https://github.com/colinhacks/zod/pull/5599) - Georgian translation fix: [#&#8203;5655](https://github.com/colinhacks/zod/pull/5655) - French issue origin translations: [#&#8203;5845](https://github.com/colinhacks/zod/pull/5845) - Italian validation message updates: [#&#8203;5852](https://github.com/colinhacks/zod/pull/5852) Locale message text changed in some cases, which may affect snapshots. #### Closed issues The following issues were closed by PRs included in this release: - Closed [#&#8203;5466](https://github.com/colinhacks/zod/issues/5466) via [#&#8203;5632](https://github.com/colinhacks/zod/pull/5632): preserve context immutability in parse functions. - Closed [#&#8203;5617](https://github.com/colinhacks/zod/issues/5617) via [#&#8203;5655](https://github.com/colinhacks/zod/pull/5655): correct Georgian translation for `string`. - Closed [#&#8203;5619](https://github.com/colinhacks/zod/issues/5619) via [#&#8203;5657](https://github.com/colinhacks/zod/pull/5657): add Romanian locale. - Closed [#&#8203;5229](https://github.com/colinhacks/zod/issues/5229) via [#&#8203;5661](https://github.com/colinhacks/zod/pull/5661): align object and tuple optionality handling. - Closed [#&#8203;5680](https://github.com/colinhacks/zod/issues/5680) via [#&#8203;5681](https://github.com/colinhacks/zod/pull/5681): respect `abort: true` in `.refine()` checks with `when`. - Closed [#&#8203;5678](https://github.com/colinhacks/zod/issues/5678) via [#&#8203;5699](https://github.com/colinhacks/zod/pull/5699): add missing `addIssue` to transform context. - Closed [#&#8203;5717](https://github.com/colinhacks/zod/issues/5717) via [#&#8203;5718](https://github.com/colinhacks/zod/pull/5718): avoid `delete` in `finalizeIssue`. - Closed [#&#8203;5714](https://github.com/colinhacks/zod/issues/5714) via [#&#8203;5719](https://github.com/colinhacks/zod/pull/5719): skip non-enumerable properties in record validation. - Closed [#&#8203;5670](https://github.com/colinhacks/zod/issues/5670) via [#&#8203;5723](https://github.com/colinhacks/zod/pull/5723): add discriminator `options` to invalid discriminator errors. - Closed [#&#8203;5743](https://github.com/colinhacks/zod/issues/5743) via [#&#8203;5744](https://github.com/colinhacks/zod/pull/5744): increase timeout for the datetime ReDoS checker test. - Closed [#&#8203;5732](https://github.com/colinhacks/zod/issues/5732) via [#&#8203;5758](https://github.com/colinhacks/zod/pull/5758): apply description and default metadata in `fromJSONSchema()`. - Closed [#&#8203;5731](https://github.com/colinhacks/zod/issues/5731) via [#&#8203;5759](https://github.com/colinhacks/zod/pull/5759): strip redundant `id` from `$defs` entries in JSON Schema output. - Closed [#&#8203;5605](https://github.com/colinhacks/zod/issues/5605) via [#&#8203;5763](https://github.com/colinhacks/zod/pull/5763): update `z.custom()` docs for v4 compatibility. - Closed [#&#8203;5593](https://github.com/colinhacks/zod/issues/5593) via [#&#8203;5769](https://github.com/colinhacks/zod/pull/5769): support `discriminatedUnion().encode()` with codec discriminators. - Closed [#&#8203;5625](https://github.com/colinhacks/zod/issues/5625) via [#&#8203;5770](https://github.com/colinhacks/zod/pull/5770): add codec inversion. - Closed [#&#8203;5778](https://github.com/colinhacks/zod/issues/5778) via [#&#8203;5779](https://github.com/colinhacks/zod/pull/5779): add custom docs 404 page. - Closed [#&#8203;5792](https://github.com/colinhacks/zod/issues/5792) via [#&#8203;5793](https://github.com/colinhacks/zod/pull/5793): correct floating-point `multipleOf()` validation. - Closed [#&#8203;5777](https://github.com/colinhacks/zod/issues/5777) via [#&#8203;5797](https://github.com/colinhacks/zod/pull/5797): resolve recursive lazy JSON Schema stack overflow. - Closed [#&#8203;5805](https://github.com/colinhacks/zod/issues/5805) via [#&#8203;5812](https://github.com/colinhacks/zod/pull/5812): fix self-referencing schema docs. - Closed [#&#8203;5826](https://github.com/colinhacks/zod/issues/5826) via [#&#8203;5855](https://github.com/colinhacks/zod/pull/5855): clone `Map` and `Set` defaults. - Closed [#&#8203;5842](https://github.com/colinhacks/zod/issues/5842) via [#&#8203;5856](https://github.com/colinhacks/zod/pull/5856): align `.merge()` refinement semantics with `.extend()`. - Closed [#&#8203;4461](https://github.com/colinhacks/zod/issues/4461) and [#&#8203;5414](https://github.com/colinhacks/zod/issues/5414) via [#&#8203;5864](https://github.com/colinhacks/zod/pull/5864): honor `jitless` config in the eval probe. - Closed [#&#8203;5868](https://github.com/colinhacks/zod/issues/5868) via [#&#8203;5869](https://github.com/colinhacks/zod/pull/5869): handle empty `z.union([])` and `z.xor([])`. - Closed [#&#8203;5296](https://github.com/colinhacks/zod/issues/5296) via [#&#8203;5891](https://github.com/colinhacks/zod/pull/5891): apply key schema transforms in `z.record()`. - Closed [#&#8203;5824](https://github.com/colinhacks/zod/issues/5824) via [#&#8203;5893](https://github.com/colinhacks/zod/pull/5893): emit falsy prefault values in JSON Schema output. #### Commits - Commit [`44f6a03e`](https://github.com/colinhacks/zod/commit/44f6a03e1d7cd918bfb9d9962d967deb6718335b) fix(locales): correct Georgian translation for 'string' to 'ველი' ([#&#8203;5655](https://github.com/colinhacks/zod/pull/5655)) by [@&#8203;tushargr0ver](https://github.com/tushargr0ver) - Commit [`7b43bc64`](https://github.com/colinhacks/zod/commit/7b43bc64e7a2720fe66d6e99239c2a00c782e06b) docs(ecosystem): add Hono Takibi ([#&#8203;5651](https://github.com/colinhacks/zod/pull/5651)) by [@&#8203;nakita628](https://github.com/nakita628) - Commit [`119376b9`](https://github.com/colinhacks/zod/commit/119376b9dc2e80f44bedd282702b46e18e2ee72c) feat: add map support to Uzbek locale ([#&#8203;5599](https://github.com/colinhacks/zod/pull/5599)) by [@&#8203;uchkunr](https://github.com/uchkunr) - Commit [`8fbf701e`](https://github.com/colinhacks/zod/commit/8fbf701e6c3770682803988bb20183f6628987da) test: add edge case tests for boundary values ([#&#8203;5601](https://github.com/colinhacks/zod/pull/5601)) by [@&#8203;uchkunr](https://github.com/uchkunr) - Commit [`f1f93c2b`](https://github.com/colinhacks/zod/commit/f1f93c2bca9984f844017c768183d2ea4b7c9cc4) Fix order of brand method examples in api.mdx ([#&#8203;5604](https://github.com/colinhacks/zod/pull/5604)) by [@&#8203;onurtemiz](https://github.com/onurtemiz) - Commit [`10105ee4`](https://github.com/colinhacks/zod/commit/10105ee40f6aba0d89454c42a49554296cabf992) docs: Fix typos in json-schema documentation ([#&#8203;5608](https://github.com/colinhacks/zod/pull/5608)) by [@&#8203;SaKaNa-Y](https://github.com/SaKaNa-Y) - Commit [`2d367139`](https://github.com/colinhacks/zod/commit/2d3671390f6cae4254642cf9ac7f16783eb6ff20) feat: add hr translation ([#&#8203;5610](https://github.com/colinhacks/zod/pull/5610)) by [@&#8203;vuki656](https://github.com/vuki656) - Commit [`54902cb7`](https://github.com/colinhacks/zod/commit/54902cb794f24f4ceb0cf8830e5a27b3490191f7) chore: update pullfrog.yml workflow - Commit [`89ba70f2`](https://github.com/colinhacks/zod/commit/89ba70f2d50d33a70549bedbd5c79785810ee21b) chore: add sideEffects false to stub package.json for tree-shaking ([#&#8203;5689](https://github.com/colinhacks/zod/pull/5689)) by [@&#8203;jesse-holden](https://github.com/jesse-holden) - Commit [`eaa3c2c3`](https://github.com/colinhacks/zod/commit/eaa3c2c3633a5e6494d8ac03c14365d181794e71) Update positive checks to use alias `.gt(0)` in the docs ([#&#8203;5671](https://github.com/colinhacks/zod/pull/5671)) by [@&#8203;Fredkiss3](https://github.com/Fredkiss3) - Commit [`65f1f404`](https://github.com/colinhacks/zod/commit/65f1f404f644cfc9b7f790d310500a05b9d30ca4) fix typo ([#&#8203;5676](https://github.com/colinhacks/zod/pull/5676)) by [@&#8203;Nikita0x](https://github.com/Nikita0x) - Commit [`5b574501`](https://github.com/colinhacks/zod/commit/5b5745014af2a3b0ea6339ccd7bbcbdf845f7181) fix: respect `abort: true` in `.refine()` for checks with `when` function ([#&#8203;5681](https://github.com/colinhacks/zod/pull/5681)) - Commit [`539de140`](https://github.com/colinhacks/zod/commit/539de140773587724723601720082a9231ba6d64) docs: fix README links for async refinements/transforms ([#&#8203;5682](https://github.com/colinhacks/zod/pull/5682)) by [@&#8203;pavan-sh](https://github.com/pavan-sh) - Commit [`46cd10e7`](https://github.com/colinhacks/zod/commit/46cd10e76339c2f9cf8ad99df49b808e58e69879) docs: fix README anchor links for async APIs ([#&#8203;5683](https://github.com/colinhacks/zod/pull/5683)) by [@&#8203;pavan-sh](https://github.com/pavan-sh) - Commit [`55747b3c`](https://github.com/colinhacks/zod/commit/55747b3cd05cd8b60b4f3d6a6348e2c508069c12) Remove deprecated downlevelIteration option ([#&#8203;5684](https://github.com/colinhacks/zod/pull/5684)) by [@&#8203;RyanCavanaugh](https://github.com/RyanCavanaugh) - Commit [`3a818de1`](https://github.com/colinhacks/zod/commit/3a818de145dc2fa9b5753bc8bf97b0b8484cfbaf) fix(v4): handle multi-digit exponents in floatSafeRemainder ([#&#8203;5687](https://github.com/colinhacks/zod/pull/5687)) by [@&#8203;shakecodeslikecray](https://github.com/shakecodeslikecray) - Commit [`3cd45ebc`](https://github.com/colinhacks/zod/commit/3cd45ebcbcf06a3f16e702a010074dfceca3ea50) fix(v4): add strict validation to `httpUrl()` ([#&#8203;5672](https://github.com/colinhacks/zod/pull/5672)) by [@&#8203;LuckySilver0021](https://github.com/LuckySilver0021) - Commit [`7d98c909`](https://github.com/colinhacks/zod/commit/7d98c909329713cb2f478620f8a67aaf3ef40ce2) add Sanity as silver sponsor and Mintlify as bronze sponsor - Commit [`c7805073`](https://github.com/colinhacks/zod/commit/c7805073fef5b6b8857307c3d4b3597a70613bc2) move Sanity and Mintlify to top of sponsor lists - Commit [`bee2dc8d`](https://github.com/colinhacks/zod/commit/bee2dc8d4971a5142d6197a01426837e2a57f69d) docs: move `z.iso.time()` from format to pattern section ([#&#8203;5696](https://github.com/colinhacks/zod/pull/5696)) - Commit [`2f8414bc`](https://github.com/colinhacks/zod/commit/2f8414bc90cebc76be87c3640617e300a5d9b060) fix: add missing addIssue to transform context ([#&#8203;5699](https://github.com/colinhacks/zod/pull/5699)) by [@&#8203;F-A-N-D-E](https://github.com/F-A-N-D-E) - Commit [`d3c0ec87`](https://github.com/colinhacks/zod/commit/d3c0ec8764ede3aa7f7c7d47cb5fa985db15be20) docs: add note about removed `.errors` alias in v4 changelog ([#&#8203;5705](https://github.com/colinhacks/zod/pull/5705)) by [@&#8203;togami2864](https://github.com/togami2864) - Commit [`fa338a3b`](https://github.com/colinhacks/zod/commit/fa338a3b885e6f8aeefc439b50982132ec0af1b5) fix(v4): JSON schema min/max intersection for draft-04 and openapi-3.0 ([#&#8203;5700](https://github.com/colinhacks/zod/pull/5700)) by [@&#8203;ebroder](https://github.com/ebroder) - Commit [`3473b288`](https://github.com/colinhacks/zod/commit/3473b288e02d536252db517a4c51b5adc23603b4) chore: bump zshy to ^0.7.1 - Commit [`cc8f9b7c`](https://github.com/colinhacks/zod/commit/cc8f9b7cb5674c0df03803d05b2a3a00569cdb07) docs: improve README wording and fix typos ([#&#8203;5736](https://github.com/colinhacks/zod/pull/5736)) by [@&#8203;vedanshshetti](https://github.com/vedanshshetti) - Commit [`f5336717`](https://github.com/colinhacks/zod/commit/f533671752ae7247bc25dca8f2dbfda80fa2fccc) feat: add json-up to ecosystem ([#&#8203;5740](https://github.com/colinhacks/zod/pull/5740)) by [@&#8203;mrspence](https://github.com/mrspence) - Commit [`60ff3987`](https://github.com/colinhacks/zod/commit/60ff398771bb4b6df04d96f00b9a10ee561ee7af) fix(v4): preserve parent path when treeifying nested union/key/element issues - Commit [`08b14b51`](https://github.com/colinhacks/zod/commit/08b14b51501335a3e0de3cb92c3b2fdeae00a0d6) perf: avoid `delete` in `finalizeIssue` to keep V8 fast mode ([#&#8203;5718](https://github.com/colinhacks/zod/pull/5718)) - Commit [`9cf868d2`](https://github.com/colinhacks/zod/commit/9cf868d20cdaf4cf80f6d33a6eaf31582f1cdeba) fix(v4): treeify error nested union bug ([#&#8203;5708](https://github.com/colinhacks/zod/pull/5708)) by [@&#8203;dstashevskyi](https://github.com/dstashevskyi) - Commit [`28f39a6d`](https://github.com/colinhacks/zod/commit/28f39a6d97ce903ed0d2f6cd99a60d390faa7adf) Add JSONType export ([#&#8203;5709](https://github.com/colinhacks/zod/pull/5709)) by [@&#8203;RobinVdBroeck](https://github.com/RobinVdBroeck) - Commit [`65fab33e`](https://github.com/colinhacks/zod/commit/65fab33e287bba2db5942c7f9ad905ac98f62fce) feat: allow `when` parameter in `.superRefine()` ([#&#8203;5741](https://github.com/colinhacks/zod/pull/5741)) by [@&#8203;vilvai](https://github.com/vilvai) - Commit [`7f87df1e`](https://github.com/colinhacks/zod/commit/7f87df1e8ae61679ed9dc3ba223572ce3d7bc716) refactor(v4): remove unnecessary type assertions ([#&#8203;5720](https://github.com/colinhacks/zod/pull/5720)) by [@&#8203;chisaki66](https://github.com/chisaki66) - Commit [`518f15dd`](https://github.com/colinhacks/zod/commit/518f15ddada3b5d959f4ff32b094789e2d85349a) Preprocess is not deprecated ([#&#8203;5721](https://github.com/colinhacks/zod/pull/5721)) by [@&#8203;mxdvl](https://github.com/mxdvl) - Commit [`2e5b23dc`](https://github.com/colinhacks/zod/commit/2e5b23dcd41eb257bda434b9997fd60a19cdf38f) fix: add options to invalid discriminator errors ([#&#8203;5723](https://github.com/colinhacks/zod/pull/5723)) by [@&#8203;Danielchinasa](https://github.com/Danielchinasa) - Commit [`7f789def`](https://github.com/colinhacks/zod/commit/7f789defd73ee35f3099ab5c2091cb19bd2b3578) fix: skip non-enumerable properties in record validation ([#&#8203;5719](https://github.com/colinhacks/zod/pull/5719)) by [@&#8203;veeceey](https://github.com/veeceey) - Commit [`ee15fa19`](https://github.com/colinhacks/zod/commit/ee15fa1905f7c6626dea5f8dc880e66cdb4700ad) docs: add AGENTS notes for JSDoc, PR comments, and PR worktree workflow - Commit [`f52b4d28`](https://github.com/colinhacks/zod/commit/f52b4d288fabb03b98ff3f893c58e285eb310e96) Revert "docs: improve README wording and fix typos ([#&#8203;5736](https://github.com/colinhacks/zod/issues/5736))" - Commit [`ddb41391`](https://github.com/colinhacks/zod/commit/ddb413916bc238e8d2d6ba67a2ce4b48ff2aa930) test: increase timeout for redos checker in datetime.test.ts ([#&#8203;5744](https://github.com/colinhacks/zod/pull/5744)) by [@&#8203;rishadaufa](https://github.com/rishadaufa) - Commit [`bc07e459`](https://github.com/colinhacks/zod/commit/bc07e459bab4f895bf1c99f182c6841d577c16b3) docs: fix doc ([#&#8203;5745](https://github.com/colinhacks/zod/pull/5745)) by [@&#8203;xgaia](https://github.com/xgaia) - Commit [`e06af5de`](https://github.com/colinhacks/zod/commit/e06af5de314f1cad8dfaa0a5f1909e21ffff9e49) Update Hey API description ([#&#8203;5748](https://github.com/colinhacks/zod/pull/5748)) by [@&#8203;mrlubos](https://github.com/mrlubos) - Commit [`28c156e2`](https://github.com/colinhacks/zod/commit/28c156e254ebdf65d9ed3de4caf1d4293f7e7a84) fix: apply description and default metadata to enum, const, and not schemas in fromJSONSchema ([#&#8203;5758](https://github.com/colinhacks/zod/pull/5758)) by [@&#8203;mibragimov](https://github.com/mibragimov) - Commit [`f457edf1`](https://github.com/colinhacks/zod/commit/f457edf1e504787eadfe2dffe51a77c64e3f0e17) Fix grammar in CONTRIBUTING.md ([#&#8203;5765](https://github.com/colinhacks/zod/pull/5765)) by [@&#8203;siekmang](https://github.com/siekmang) - Commit [`411f6c64`](https://github.com/colinhacks/zod/commit/411f6c64e910c5e18799d0a7a09bcd7a4e40f23e) fix(v4): resolve stack overflow in toJSONSchema for recursive lazy with describe ([#&#8203;5797](https://github.com/colinhacks/zod/pull/5797)) by [@&#8203;Hassad674](https://github.com/Hassad674) - Commit [`45dd421e`](https://github.com/colinhacks/zod/commit/45dd421e72e989752fa5f85529dfbf50bdbd3f61) docs: add tone guidelines for issue and PR comments to AGENTS.md - Commit [`ddd20a30`](https://github.com/colinhacks/zod/commit/ddd20a300441d7cffd59821461ed0c2fe9c96bbc) test: align optional property assertions with actual inferred types - Commit [`a1cf8a93`](https://github.com/colinhacks/zod/commit/a1cf8a9312582591d9cdccdd677ba1d90e706cc0) docs: update z.custom example for v4 compatibility ([#&#8203;5763](https://github.com/colinhacks/zod/pull/5763)) by [@&#8203;andrewdamelio](https://github.com/andrewdamelio) - Commit [`b6a3b336`](https://github.com/colinhacks/zod/commit/b6a3b3369a5b9fdde9adde8203b96b71c0634ad5) fix: strip redundant id from `$defs` entries in toJSONSchema ([#&#8203;5759](https://github.com/colinhacks/zod/pull/5759)) by [@&#8203;mibragimov](https://github.com/mibragimov) - Commit [`c7a8ccc0`](https://github.com/colinhacks/zod/commit/c7a8ccc0d0fb4f2bd1c938b8d79873a8ebd6573e) fix: discriminatedUnion encode() with codec discriminator ([#&#8203;5769](https://github.com/colinhacks/zod/pull/5769)) by [@&#8203;mahmoodhamdi](https://github.com/mahmoodhamdi) - Commit [`87cf0f93`](https://github.com/colinhacks/zod/commit/87cf0f93cd0f34bdc69f11c9377568e6812841c4) fix(fromJSONSchema): normalize input via JSON round-trip - Commit [`7163e6f2`](https://github.com/colinhacks/zod/commit/7163e6f25ae8c90be79bd588417440c047ee30b0) feat: add `.invert()` method to ZodCodec ([#&#8203;5770](https://github.com/colinhacks/zod/pull/5770)) by [@&#8203;mahmoodhamdi](https://github.com/mahmoodhamdi) - Commit [`b59b9b13`](https://github.com/colinhacks/zod/commit/b59b9b13c20397389c5d4dc3a2ecbcd5e9349395) fix: replace `.default` with `.prefault` ([#&#8203;5776](https://github.com/colinhacks/zod/pull/5776)) by [@&#8203;alanskovrlj](https://github.com/alanskovrlj) - Commit [`93bba686`](https://github.com/colinhacks/zod/commit/93bba686325e09dced20da8d7bc18c7e61b71562) docs: add Zod AOT to ecosystem page ([#&#8203;5806](https://github.com/colinhacks/zod/pull/5806)) by [@&#8203;wakita181009](https://github.com/wakita181009) - Commit [`2564caa4`](https://github.com/colinhacks/zod/commit/2564caa440e690fd3ad58ce55fdff0fe073d6cc0) fix(docs): add custom 404 page with proper theme support ([#&#8203;5779](https://github.com/colinhacks/zod/pull/5779)) by [@&#8203;WolfieLeader](https://github.com/WolfieLeader) - Commit [`5b7ed214`](https://github.com/colinhacks/zod/commit/5b7ed214526cb5a7cc508aec236603ff79ae9579) fix: correct multipleOf float validation using tolerance-based comparison ([#&#8203;5793](https://github.com/colinhacks/zod/pull/5793)) by [@&#8203;cyphercodes](https://github.com/cyphercodes) - Commit [`cc9139d2`](https://github.com/colinhacks/zod/commit/cc9139d209001bfdeb23dfe2d5b0262c02c950cf) docs: fix self-referencing schema in refine when() example ([#&#8203;5812](https://github.com/colinhacks/zod/pull/5812)) by [@&#8203;claygeo](https://github.com/claygeo) - Commit [`0e960108`](https://github.com/colinhacks/zod/commit/0e960108f0d98dbea7844a8ff914f0980352f636) fix(v4): support v3-style single-arg z.record(valueType) - Commit [`41b25af9`](https://github.com/colinhacks/zod/commit/41b25af98f108d7b6f695576d4e0330b97252bfd) docs(agents): refine PR comment tone guidance - Commit [`4c03c20d`](https://github.com/colinhacks/zod/commit/4c03c20d2bc7e013e8b80ce55380cd4b82bfe352) Update Italian locale error messages for validation ([#&#8203;5852](https://github.com/colinhacks/zod/pull/5852)) by [@&#8203;pastorello](https://github.com/pastorello) - Commit [`37ac1ba0`](https://github.com/colinhacks/zod/commit/37ac1ba0d694b3b80e22c006dc6e2b78b0c956dc) fix(fr): translate issue.origin in too\_big/too\_small errors ([#&#8203;5845](https://github.com/colinhacks/zod/pull/5845)) by [@&#8203;Ouaziz-chedli](https://github.com/Ouaziz-chedli) - Commit [`345be203`](https://github.com/colinhacks/zod/commit/345be2039463516aaac90640c14de1b697e775b6) docs: add validex to ecosystem ([#&#8203;5848](https://github.com/colinhacks/zod/pull/5848)) by [@&#8203;chiptoma](https://github.com/chiptoma) - Commit [`3c1f32bd`](https://github.com/colinhacks/zod/commit/3c1f32bd280c01b836d4790981fd769cf9041d29) feat(locales/en): handle instanceof and add comprehensive locale tests - Commit [`888e52bb`](https://github.com/colinhacks/zod/commit/888e52bb1762f8a8b881af48d9f1bdc353372af8) feat(locales): add Greek (el) locale ([#&#8203;5840](https://github.com/colinhacks/zod/pull/5840)) by [@&#8203;saileshbro](https://github.com/saileshbro) - Commit [`bf6d99ed`](https://github.com/colinhacks/zod/commit/bf6d99ed76be86e4871d2381ecd9832293c13406) Revert "feat(locales/en): handle instanceof and add comprehensive locale tests" - Commit [`e8196a8d`](https://github.com/colinhacks/zod/commit/e8196a8d98e3bc3cc6714ef5ff34b5abf33eff4a) fix(resolution): align expected fr message with translated locale - Commit [`b6b12882`](https://github.com/colinhacks/zod/commit/b6b1288277e6ca87dab0ad1c7251b92612b7445c) correct logic for validating length ([#&#8203;5843](https://github.com/colinhacks/zod/pull/5843)) by [@&#8203;nameearly](https://github.com/nameearly) - Commit [`34f60159`](https://github.com/colinhacks/zod/commit/34f601590351e5d3a57fe20c001155940ba65324) fix(v4): clone Map and Set in shallowClone to prevent shared state across `.default()` parses ([#&#8203;5855](https://github.com/colinhacks/zod/pull/5855)) by [@&#8203;artur-seppa](https://github.com/artur-seppa) - Commit [`91a7d0d1`](https://github.com/colinhacks/zod/commit/91a7d0d1e0d3c8338e9fd92cf819cded87e8973f) fix(v4): reject whitespace in z.base64() to close atob bypass - Commit [`23edf484`](https://github.com/colinhacks/zod/commit/23edf4844bcd89fa37c549dab187ce7f86728540) Revert "fix(v4): reject whitespace in z.base64() to close atob bypass" - Commit [`15cafa13`](https://github.com/colinhacks/zod/commit/15cafa13940b7055cc21e4ef440a6a0c6b7af72b) fix(v4): throw on `.merge()` receiver with refinements; preserve refinements from second schema ([#&#8203;5856](https://github.com/colinhacks/zod/pull/5856)) by [@&#8203;solssak](https://github.com/solssak) - Commit [`584b1089`](https://github.com/colinhacks/zod/commit/584b1089e1fc7bfcc97797576eff8da85bcdf031) fix(v4): reject whitespace in z.base64() to close atob bypass ([#&#8203;5888](https://github.com/colinhacks/zod/pull/5888)) by [@&#8203;colinhacks](https://github.com/colinhacks) - Commit [`b9b62c65`](https://github.com/colinhacks/zod/commit/b9b62c65357c2b0fed4ae046a30c8e84e4094202) fix(core): honour `jitless` config in `allowsEval` probe ([#&#8203;5864](https://github.com/colinhacks/zod/pull/5864)) by [@&#8203;dokson](https://github.com/dokson) - Commit [`fffe99bd`](https://github.com/colinhacks/zod/commit/fffe99bdd7445cc072b5ed2d74b2a6204bdbc86c) fix(v4): construct empty unions instead of crashing ([#&#8203;5869](https://github.com/colinhacks/zod/pull/5869)) by [@&#8203;tjenkinson](https://github.com/tjenkinson) - Commit [`285bde7f`](https://github.com/colinhacks/zod/commit/285bde7f43ca66938eeac38dea852256d4757336) feat(core): share `globalConfig` across module systems via `globalThis` ([#&#8203;5889](https://github.com/colinhacks/zod/pull/5889)) by [@&#8203;colinhacks](https://github.com/colinhacks) - Commit [`195e8696`](https://github.com/colinhacks/zod/commit/195e86962b5156012a4cdcfbff87dffddce87b78) perf(v4): mark top-level factory calls as `/*@&#8203;__PURE__*/` for tree-shaking - Commit [`61d7bedb`](https://github.com/colinhacks/zod/commit/61d7bedb873bf8185162bb51d027fd8acf2710ee) fix(v4): apply key schema transforms in z.record() ([#&#8203;5891](https://github.com/colinhacks/zod/pull/5891)) by [@&#8203;colinhacks](https://github.com/colinhacks) - Commit [`45acd2ad`](https://github.com/colinhacks/zod/commit/45acd2ad78fb34ef61c5b72e9c03dfeaa432bef9) ci(release): switch to npm trusted publishing via OIDC ([#&#8203;5890](https://github.com/colinhacks/zod/pull/5890)) by [@&#8203;colinhacks](https://github.com/colinhacks) - Commit [`476ae243`](https://github.com/colinhacks/zod/commit/476ae243e86344af08d6c396deed082e83d7d7e1) Tighten cuid() regex and deprecate CUID v1 ([#&#8203;5880](https://github.com/colinhacks/zod/pull/5880)) by [@&#8203;colinhacks](https://github.com/colinhacks) - Commit [`6217527e`](https://github.com/colinhacks/zod/commit/6217527e4880054dda5e4d33aa12192a36a35062) docs(agents): document push-to-main footgun and version-bump rule ([#&#8203;5883](https://github.com/colinhacks/zod/pull/5883)) by [@&#8203;colinhacks](https://github.com/colinhacks) - Commit [`757f0b0f`](https://github.com/colinhacks/zod/commit/757f0b0f5217e0e7125478cd91af1e2c0cd21aa9) fix(v4): apply util.Writeable<T> in strictObject/looseObject for shape display parity ([#&#8203;5882](https://github.com/colinhacks/zod/pull/5882)) by [@&#8203;colinhacks](https://github.com/colinhacks) - Commit [`fa4a3740`](https://github.com/colinhacks/zod/commit/fa4a37404966d7ada0f5bb02ceeb592f1d4d9c52) fix(v4): apply util.Writeable in mini object constructors and extend/safeExtend/partial/required ([#&#8203;5895](https://github.com/colinhacks/zod/pull/5895)) by [@&#8203;colinhacks](https://github.com/colinhacks) - Commit [`ebc8287c`](https://github.com/colinhacks/zod/commit/ebc8287ca206402cf3a9aceb745b204493cbadfb) fix(v4): emit falsy prefault values in toJSONSchema ([#&#8203;5893](https://github.com/colinhacks/zod/pull/5893)) by [@&#8203;mixelburg](https://github.com/mixelburg) - Commit [`8fcb71a5`](https://github.com/colinhacks/zod/commit/8fcb71a5ffa5b32a508ac8bb38b7e1e13c387bf5) perf(v4): lazy-bind builder methods to shared internal prototype ([#&#8203;5897](https://github.com/colinhacks/zod/pull/5897)) by [@&#8203;colinhacks](https://github.com/colinhacks) - Commit [`76e8f706`](https://github.com/colinhacks/zod/commit/76e8f706bb554de82234106de8299d0139cb3b8e) fix(v4): skip `__proto__` key in object catchall ([#&#8203;5898](https://github.com/colinhacks/zod/pull/5898)) by [@&#8203;colinhacks](https://github.com/colinhacks) - Commit [`f0b0608e`](https://github.com/colinhacks/zod/commit/f0b0608ee300e609772405501ab4b219f0e19680) ecosystem: `eslint-plugin-zod-x` is `eslint-plugin-zod` now ([#&#8203;5637](https://github.com/colinhacks/zod/pull/5637)) by [@&#8203;marcalexiei](https://github.com/marcalexiei) - Commit [`0b5c3bc2`](https://github.com/colinhacks/zod/commit/0b5c3bc2b9e095e06687d2381bdd741185fbfee9) docs: fix refinements examples in api.mdx ([#&#8203;5649](https://github.com/colinhacks/zod/pull/5649)) by [@&#8203;playoffthecuff](https://github.com/playoffthecuff) - Commit [`327e152e`](https://github.com/colinhacks/zod/commit/327e152e463c85e6404388738d397ed92e5f3999) docs(agents): refine PR comment tone guidance further - Commit [`57d80a82`](https://github.com/colinhacks/zod/commit/57d80a82bde8877f3eb79e5dad9786096c37490f) test(v4): pin object/tuple key optionality through optout propagation - Commit [`f19860f1`](https://github.com/colinhacks/zod/commit/f19860f1f17e3bdc3e696ee5290441bba093d7a4) fix: preserve context immutability in parse functions ([#&#8203;5632](https://github.com/colinhacks/zod/pull/5632)) by [@&#8203;bgk614](https://github.com/bgk614) - Commit [`ec979ad7`](https://github.com/colinhacks/zod/commit/ec979ad783a9e9c992d3c9bd4e5f3b56110b1ef8) feat: add Romanian (ro) locale ([#&#8203;5657](https://github.com/colinhacks/zod/pull/5657)) by [@&#8203;tushargr0ver](https://github.com/tushargr0ver) - Commit [`b6066b3e`](https://github.com/colinhacks/zod/commit/b6066b3e4730fc8b966d13974b4abae8dce25df4) fix(v4): align object and tuple optionality handling ([#&#8203;5661](https://github.com/colinhacks/zod/pull/5661)) by [@&#8203;Cyjin-jani](https://github.com/Cyjin-jani) - Commit [`ad0b8271`](https://github.com/colinhacks/zod/commit/ad0b82713e70e53707dd5e6497c9d922fcba3721) ci: update release workflow for trusted publishing - Commit [`6db607be`](https://github.com/colinhacks/zod/commit/6db607be3c218ad9f23fef8975de1f37469680e7) fix(release): keep JSR manifest publishable - Commit [`f778e02a`](https://github.com/colinhacks/zod/commit/f778e02a81842cbc40b1a448a85b29747227c49d) build: bump zshy for JSR wildcard exports ### [`v4.3.6`](https://github.com/colinhacks/zod/releases/tag/v4.3.6) [Compare Source](https://github.com/colinhacks/zod/compare/v4.3.5...v4.3.6) #### Commits: - [`9977fb0`](https://github.com/colinhacks/zod/commit/9977fb0868432461de265a773319e80a90ba3e37) Add brand.dev to sponsors - [`f4b7bae`](https://github.com/colinhacks/zod/commit/f4b7bae3468f6188b8f004e007d722148fc91d77) Update pullfrog.yml ([#&#8203;5634](https://github.com/colinhacks/zod/issues/5634)) - [`251d716`](https://github.com/colinhacks/zod/commit/251d7163a0ac7740fee741428d913e3c55702ace) Clean up workflow\_call - [`edd4132`](https://github.com/colinhacks/zod/commit/edd4132466da0f5065a8e051b599d01fdd1081d8) fix: add missing User-agent to robots.txt and allow all ([#&#8203;5646](https://github.com/colinhacks/zod/issues/5646)) - [`85db85e`](https://github.com/colinhacks/zod/commit/85db85e9091d0706910d60c7eb2e9c181edd87bd) fix: typo in codec.test.ts file ([#&#8203;5628](https://github.com/colinhacks/zod/issues/5628)) - [`cbf77bb`](https://github.com/colinhacks/zod/commit/cbf77bb12bdfda2e054818e79001f5cb3798ce76) Avoid non null assertion ([#&#8203;5638](https://github.com/colinhacks/zod/issues/5638)) - [`dfbbf1c`](https://github.com/colinhacks/zod/commit/dfbbf1c1ae0c224b8131d80ddf0a264262144086) Avoid re-exported star modules ([#&#8203;5656](https://github.com/colinhacks/zod/issues/5656)) - [`762e911`](https://github.com/colinhacks/zod/commit/762e911e5773f949452fd6dd4e360f2362110e8e) Generalize numeric key handling - [`ca3c862`](https://github.com/colinhacks/zod/commit/ca3c8629c0c2715571f70b44c2433cad3db7fe4e) v4.3.6 ### [`v4.3.5`](https://github.com/colinhacks/zod/releases/tag/v4.3.5) [Compare Source](https://github.com/colinhacks/zod/compare/v4.3.4...v4.3.5) #### Commits: - [`21afffd`](https://github.com/colinhacks/zod/commit/21afffdb42ccab554036312e33fed0ea3cb8f982) \[Docs] Update migration guide docs for deprecation of message ([#&#8203;5595](https://github.com/colinhacks/zod/issues/5595)) - [`e36743e`](https://github.com/colinhacks/zod/commit/e36743e513aadb307b29949a80d6eb0dcc8fc278) Improve mini treeshaking - [`0cdc0b8`](https://github.com/colinhacks/zod/commit/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c) 4.3.5 ### [`v4.3.4`](https://github.com/colinhacks/zod/releases/tag/v4.3.4) [Compare Source](https://github.com/colinhacks/zod/compare/v4.3.3...v4.3.4) #### Commits: - [`1a8bea3`](https://github.com/colinhacks/zod/commit/1a8bea3b474eada6f219c163d0d3ad09fadabe72) Add integration tests - [`e01cd02`](https://github.com/colinhacks/zod/commit/e01cd02b2f23d7e9078d3813830b146f8a2258b4) Support patternProperties for looserecord ([#&#8203;5592](https://github.com/colinhacks/zod/issues/5592)) - [`089e5fb`](https://github.com/colinhacks/zod/commit/089e5fbb0f58ce96d2c4fb34cd91724c78df4af5) Improve looseRecord docs - [`decef9c`](https://github.com/colinhacks/zod/commit/decef9c418d9a598c3f1bada06891ba5d922c5cd) Fix lint - [`9443aab`](https://github.com/colinhacks/zod/commit/9443aab00d44d5d5f4a7eada65fc0fc851781042) Drop iso time in fromJSONSchema - [`66bda74`](https://github.com/colinhacks/zod/commit/66bda7491a1b9eab83bdeec0c12f4efc7290bd48) Remove .refine() from ZodMiniType - [`b4ab94c`](https://github.com/colinhacks/zod/commit/b4ab94ca608cd5b581bfc12b20dd8d95b35b3009) 4.3.4 ### [`v4.3.3`](https://github.com/colinhacks/zod/releases/tag/v4.3.3) [Compare Source](https://github.com/colinhacks/zod/compare/v4.3.2...v4.3.3) #### Commits: - [`f3b2151`](https://github.com/colinhacks/zod/commit/f3b2151959d215d405f54dff3c7ab3bf1fd887ca) v4.3.3 ### [`v4.3.2`](https://github.com/colinhacks/zod/releases/tag/v4.3.2) [Compare Source](https://github.com/colinhacks/zod/compare/v4.3.1...v4.3.2) #### Commits: - [`bf96635`](https://github.com/colinhacks/zod/commit/bf96635d243118de6e4f260077aa137453790bf6) Loosen strictObjectinside intersection ([#&#8203;5587](https://github.com/colinhacks/zod/issues/5587)) - [`f71dc01`](https://github.com/colinhacks/zod/commit/f71dc0182ab0f0f9a6be6295b07faca269e10179) Remove Juno ([#&#8203;5590](https://github.com/colinhacks/zod/issues/5590)) - [`0f41e5a`](https://github.com/colinhacks/zod/commit/0f41e5a12a43e6913c9dcb501b2b5136ea86500d) 4.3.2 ### [`v4.3.1`](https://github.com/colinhacks/zod/releases/tag/v4.3.1) [Compare Source](https://github.com/colinhacks/zod/compare/v4.3.0...v4.3.1) #### Commits: - [`0fe8840`](https://github.com/colinhacks/zod/commit/0fe88407a4149c907929b757dc6618d8afe998fc) allow non-overwriting extends with refinements. 4.3.1 ### [`v4.3.0`](https://github.com/colinhacks/zod/releases/tag/v4.3.0) [Compare Source](https://github.com/colinhacks/zod/compare/v4.2.1...v4.3.0) This is Zod's biggest release since 4.0. It addresses several of Zod's longest-standing feature requests. #### `z.fromJSONSchema()` Convert JSON Schema to Zod ([#&#8203;5534](https://github.com/colinhacks/zod/pull/5534), [#&#8203;5586](https://github.com/colinhacks/zod/pull/5586)) You can now convert JSON Schema definitions directly into Zod schemas. This function supports JSON Schema `"draft-2020-12"`, `"draft-7"`, `"draft-4"`, and OpenAPI 3.0. ```typescript import * as z from "zod"; const schema = z.fromJSONSchema({ type: "object", properties: { name: { type: "string", minLength: 1 }, age: { type: "integer", minimum: 0 }, }, required: ["name"], }); schema.parse({ name: "Alice", age: 30 }); // ✅ ``` The API should be considered experimental. There are no guarantees of 1:1 "round-trip soundness": `MySchema` > `z.toJSONSchema()` > `z.fromJSONSchema()`. There are several features of Zod that don't exist in JSON Schema and vice versa, which makes this virtually impossible. Features supported: - All primitive types (`string`, `number`, `integer`, `boolean`, `null`, `object`, `array`) - String formats (`email`, `uri`, `uuid`, `date-time`, `date`, `time`, `ipv4`, `ipv6`, and more) - Composition (`anyOf`, `oneOf`, `allOf`) - Object constraints (`additionalProperties`, `patternProperties`, `propertyNames`) - Array constraints (`prefixItems`, `items`, `minItems`, `maxItems`) - `$ref` for local references and circular schemas - Custom metadata is preserved #### `z.xor()` — exclusive union ([#&#8203;5534](https://github.com/colinhacks/zod/pull/5534)) A new exclusive union type that requires **exactly one** option to match. Unlike `z.union()` which passes if *any* option matches, `z.xor()` fails if zero or more than one option matches. ```typescript const schema = z.xor([z.string(), z.number()]); schema.parse("hello"); // ✅ schema.parse(42); // ✅ schema.parse(true); // ❌ zero matches ``` When converted to JSON Schema, `z.xor()` produces `oneOf` instead of `anyOf`. #### `z.looseRecord()` — partial record validation ([#&#8203;5534](https://github.com/colinhacks/zod/pull/5534)) A new record variant that only validates keys matching the key schema, passing through non-matching keys unchanged. This is used to represent `patternProperties` in JSON Schema. ```typescript const schema = z.looseRecord(z.string().regex(/^S_/), z.string()); schema.parse({ S_name: "John", other: 123 }); // ✅ { S_name: "John", other: 123 } // only S_name is validated, "other" passes through ``` #### `.exactOptional()` — strict optional properties ([#&#8203;5589](https://github.com/colinhacks/zod/pull/5589)) A new wrapper that makes a property *key-optional* (can be omitted) but does **not** accept `undefined` as an explicit value. ```typescript const schema = z.object({ a: z.string().optional(), // accepts `undefined` b: z.string().exactOptional(), // does not accept `undefined` }); schema.parse({}); // ✅ schema.parse({ a: undefined }); // ✅ schema.parse({ b: undefined }); // ❌ ``` This makes it possible to accurately represent the full spectrum of optionality expressible using [`exactOptionalPropertyTypes`](https://www.typescriptlang.org/tsconfig/exactOptionalPropertyTypes.html). #### `.apply()` A utility method for applying arbitrary transformations to a schema, enabling cleaner schema composition. ([#&#8203;5463](https://github.com/colinhacks/zod/pull/5463)) ```typescript const setCommonChecks = <T extends z.ZodNumber>(schema: T) => { return schema.min(0).max(100); }; const schema = z.number().apply(setCommonChecks).nullable(); ``` #### `.brand()` cardinality The `.brand()` method now accepts a second argument to control whether the brand applies to input, output, or both. Closes [#&#8203;4764](https://github.com/colinhacks/zod/issues/4764), [#&#8203;4836](https://github.com/colinhacks/zod/issues/4836). ```typescript // output only (default) z.string().brand<"UserId">(); // output is branded (default) z.string().brand<"UserId", "out">(); // output is branded z.string().brand<"UserId", "in">(); // input is branded z.string().brand<"UserId", "inout">(); // both are branded ``` #### Type predicates on `.refine()` ([#&#8203;5575](https://github.com/colinhacks/zod/pull/5575)) The `.refine()` method now supports type predicates to narrow the output type: ```typescript const schema = z.string().refine((s): s is "a" => s === "a"); type Input = z.input<typeof schema>; // string type Output = z.output<typeof schema>; // "a" ``` #### `ZodMap` methods: `min`, `max`, `nonempty`, `size` ([#&#8203;5316](https://github.com/colinhacks/zod/pull/5316)) `ZodMap` now has parity with `ZodSet` and `ZodArray`: ```typescript const schema = z.map(z.string(), z.number()) .min(1) .max(10) .nonempty(); schema.size; // access the size constraint ``` #### `.with()` alias for `.check()` ([359c0db](https://github.com/colinhacks/zod/commit/359c0db6)) A new `.with()` method has been added as a more readable alias for `.check()`. Over time, more APIs have been added that don't qualify as "checks". The new method provides a readable alternative that doesn't muddy semantics. ```typescript z.string().with( z.minLength(5), z.toLowerCase() ); // equivalent to: z.string().check( z.minLength(5), z.trim(), z.toLowerCase() ); ``` #### `z.slugify()` transform Transform strings into URL-friendly slugs. Works great with `.with()`: ```typescript // Zod z.string().slugify().parse("Hello World"); // "hello-world" // Zod Mini // using .with() for explicit check composition z.string().with(z.slugify()).parse("Hello World"); // "hello-world" ``` #### `z.meta()` and `z.describe()` in Zod Mini ([947b4eb](https://github.com/colinhacks/zod/commit/947b4eb2)) Zod Mini now exports `z.meta()` and `z.describe()` as top-level functions for adding metadata to schemas: ```typescript import * as z from "zod/mini"; // add description const schema = z.string().with( z.describe("A user's name"), ); // add arbitrary metadata const schema2 = z.number().with( z.meta({ deprecated: true }) ); ``` #### More ergonomic intersections [#&#8203;5587](https://github.com/colinhacks/zod/pull/5587) When intersecting schemas that include `z.strictObject()`, Zod 4 now only rejects keys that are unrecognized by *both* sides of the intersection. Previously, any unrecognized key from either side would cause an error. This means keys that are recognized by at least one side of the intersection will now pass validation: ```ts const A = z.strictObject({ a: z.string() }); const B = z.object({ b: z.string() }); const C = z.intersection(A, B); // Keys recognized by either side now work C.parse({ a: "foo", b: "bar" }); // ✅ { a: "foo", b: "bar" } // Extra keys are stripped (follows strip behavior from B) C.parse({ a: "foo", b: "bar", c: "extra" }); // ✅ { a: "foo", b: "bar" } ``` When both sides are strict, only keys unrecognized by *both* sides will error: ```ts const A = z.strictObject({ a: z.string() }); const B = z.strictObject({ b: z.string() }); const C = z.intersection(A, B); // Keys recognized by either side work C.parse({ a: "foo", b: "bar" }); // ✅ // Keys unrecognized by BOTH sides error C.parse({ a: "foo", b: "bar", c: "extra" }); // ❌ ZodError: Unrecognized key: "c" ``` #### New locales - Armenian (`am`) ([#&#8203;5531](https://github.com/colinhacks/zod/pull/5531)) - Uzbek (`uz`) ([#&#8203;5519](https://github.com/colinhacks/zod/pull/5519)) ```ts import * as z from "zod"; import { uz } from "zod/locales"; z.config(uz()); ``` <br/><br/><br/> #### Bug fixes All of these changes fix soundness issues in Zod. As with any bug fix there's some chance of breakage if you were intentionally or unintentionally relying on this unsound behavior. ##### ⚠️ `.pick()` and `.omit()` disallowed on object schemas containing refinements ([#&#8203;5317](https://github.com/colinhacks/zod/pull/5317)) Using `.pick()` or `.omit()` on object schemas with refinements now throws an error. Previously, this would silently drop the refinements, leading to unexpected behavior. ```typescript const schema = z.object({ password: z.string(), confirmPassword: z.string(), }).refine(data => data.password === data.confirmPassword); schema.pick({ password: true }); // 4.2: refinement silently dropped ⚠️ // 4.3: throws error ❌ ``` **Migration**: The easiest way to migrate is to create a new schema using the `shape` of the old one. ```ts const newSchema = z.object(schema.shape).pick({ ... }) ``` ##### ⚠️ overwriting properties with`.extend()` disallowed on object schemas with refinements ([#&#8203;5317](https://github.com/colinhacks/zod/pull/5317)) Similarly, `.extend()` will throws on schemas with refinements *if* you are overwriting existing properties. ```typescript const schema = z.object({ a: z.string() }).refine(/* ... */); schema.extend({ a: z.number() }); // 4.3: throws error ❌ ``` Instead you can use `.safeExtend()`, which statically ensures that you aren't changing the type signature of any pre-existing properties. ```typescript const schema = z.object({ a: z.string(), }).refine(/* ... */); schema.safeExtend({ a: z.string().min(5).max(10) }); // ✅ allows overwrite, preserves refinement ``` ##### ⚠️ Stricter object masking methods ([#&#8203;5581](https://github.com/colinhacks/zod/pull/5581)) Object masking methods (`.pick()`, `.omit()`) now validate that the keys provided actually exist in the schema: ```typescript const schema = z.object({ a: z.string() }); // 4.3: throws error for unrecognized keys schema.pick({ nonexistent: true }); // error: unrecognized key: "nonexistent" ``` <br/><br/><br/> #### Additional changes - Fixed JSON Schema generation for `z.iso.time` with minute precision ([#&#8203;5557](https://github.com/colinhacks/zod/pull/5557)) - Fixed error details for tuples with extraneous elements ([#&#8203;5555](https://github.com/colinhacks/zod/pull/5555)) - Fixed `includes` method params typing to accept `string | $ZodCheckIncludesParams` ([#&#8203;5556](https://github.com/colinhacks/zod/pull/5556)) - Fixed numeric formats error messages to be inclusive ([#&#8203;5485](https://github.com/colinhacks/zod/pull/5485)) - Fixed `implementAsync` inferred type to always be a promise ([#&#8203;5476](https://github.com/colinhacks/zod/pull/5476)) - Tightened E.164 regex to require a non-zero leading digit and 7–15 digits total ([#&#8203;5524](https://github.com/colinhacks/zod/pull/5524)) - Fixed Dutch (nl) error strings ([#&#8203;5529](https://github.com/colinhacks/zod/pull/5529)) - Convert `Date` instances to numbers in `minimum`/`maximum` checks ([#&#8203;5351](https://github.com/colinhacks/zod/pull/5351)) - Improved numeric keys handling in `z.record()` ([#&#8203;5585](https://github.com/colinhacks/zod/pull/5585)) - Lazy initialization of `~standard` schema property ([#&#8203;5363](https://github.com/colinhacks/zod/pull/5363)) - Functions marked as `@__NO_SIDE_EFFECTS__` for better tree-shaking ([#&#8203;5475](https://github.com/colinhacks/zod/pull/5475)) - Improved metadata tracking across child-parent relationships ([#&#8203;5578](https://github.com/colinhacks/zod/pull/5578)) - Improved locale translation approach ([#&#8203;5584](https://github.com/colinhacks/zod/pull/5584)) - Dropped id uniqueness enforcement at registry level ([#&#8203;5574](https://github.com/colinhacks/zod/pull/5574)) ### [`v4.2.1`](https://github.com/colinhacks/zod/releases/tag/v4.2.1) [Compare Source](https://github.com/colinhacks/zod/compare/v4.2.0...v4.2.1) #### Commits: - [`5b5b129`](https://github.com/colinhacks/zod/commit/5b5b129315fbc94a3b0d6244185eaeefcbe438d1) 4.2.1 ### [`v4.2.0`](https://github.com/colinhacks/zod/releases/tag/v4.2.0) [Compare Source](https://github.com/colinhacks/zod/compare/v4.1.13...v4.2.0) #### Features ##### Implement Standard JSON Schema [standard-schema/standard-schema#134](https://github.com/standard-schema/standard-schema/pull/134) ##### Implement `z.fromJSONSchema()` ```typescript const jsonSchema = { type: "object", properties: { name: { type: "string" }, age: { type: "number" } }, required: ["name"] }; const schema = z.fromJSONSchema(jsonSchema); ``` ##### Implement `z.xor()` ```typescript const schema = z.xor( z.object({ type: "user", name: z.string() }), z.object({ type: "admin", role: z.string() }) ); // Exactly one of the schemas must match ``` ##### Implement `z.looseRecord()` ```typescript const schema = z.looseRecord(z.string(), z.number()); // Allows additional properties beyond those defined ``` #### Commits: - [`af49c08`](https://github.com/colinhacks/zod/commit/af49c084f66339110d00e37ff71dc7b3b9f2b7ef) Update docs for JSON Schema conversion of `z.undefined()` ([#&#8203;5504](https://github.com/colinhacks/zod/issues/5504)) - [`767f320`](https://github.com/colinhacks/zod/commit/767f320318986e422f524b939f1a7174544fda2e) Add `.toJSONSchema()` method ([#&#8203;5477](https://github.com/colinhacks/zod/issues/5477)) - [`e17dcb6`](https://github.com/colinhacks/zod/commit/e17dcb63573397063e87d7c7fe10a5a78968181a) Add `z.fromJSONSchema()`, `z.looseRecord()`, `z.xor()` ([#&#8203;5534](https://github.com/colinhacks/zod/issues/5534)) ### [`v4.1.13`](https://github.com/colinhacks/zod/releases/tag/v4.1.13) [Compare Source](https://github.com/colinhacks/zod/compare/v4.1.12...v4.1.13) #### Commits: - [`5c2602c`](https://github.com/colinhacks/zod/commit/5c2602ceb8be8941c64bbe5ac7d92cc174ae6f7e) Update AI widget ([#&#8203;5318](https://github.com/colinhacks/zod/issues/5318)) - [`d3da530`](https://github.com/colinhacks/zod/commit/d3da530deb713c853e79405adddf770e156d50ac) reflect the specified regex correctly in error ([#&#8203;5338](https://github.com/colinhacks/zod/issues/5338)) - [`39f8c45`](https://github.com/colinhacks/zod/commit/39f8c45b8a29de2330b485862b83cb35849f4238) faster initialization ([#&#8203;5352](https://github.com/colinhacks/zod/issues/5352)) - [`e9e2790`](https://github.com/colinhacks/zod/commit/e9e27905cc0f37cb079ea473af8359d5e17a57a1) Clean up comment - [`8e4739f`](https://github.com/colinhacks/zod/commit/8e4739fadbd7de710eb67d34ba7e06a1029a68ab) Update inferred z.promise() type - [`2849df8`](https://github.com/colinhacks/zod/commit/2849df8907b011ab056d67ae8e3d27577ac4ed3e) fix(locales): improve Dutch (nl) localization ([#&#8203;5367](https://github.com/colinhacks/zod/issues/5367)) - [`b0d3c9f`](https://github.com/colinhacks/zod/commit/b0d3c9f628b60d358b66acf8f0ef7937fc9e8950) Run tests on windows - [`6fd61b7`](https://github.com/colinhacks/zod/commit/6fd61b71b85e4fef4c168a46c3ebcc574f26255f) feat unitest ([#&#8203;5358](https://github.com/colinhacks/zod/issues/5358)) - [`a4e4bc8`](https://github.com/colinhacks/zod/commit/a4e4bc80e204577c698cf1369dd63c2b986d35f3) Lock to node 24 - [`8de8bad`](https://github.com/colinhacks/zod/commit/8de8bad0fa84194b81efd32474462d7a236a1ee4) Fix windows build - [`b2c186b`](https://github.com/colinhacks/zod/commit/b2c186bbae3a74a12acd385c1ced3ed978235cf8) Use Node LTS - [`b73b1f6`](https://github.com/colinhacks/zod/commit/b73b1f61c798efdf497852872b4c19cd4111c1f3) Consolidate isTransforming logic - [`d85f3ea`](https://github.com/colinhacks/zod/commit/d85f3ea4da53a1b232017dd4e4a2874eca4d8d76) Fix [#&#8203;5353](https://github.com/colinhacks/zod/issues/5353) - [`1bac0f3`](https://github.com/colinhacks/zod/commit/1bac0f37b529eb9a0d833a01200f5a898e8e6220) Fix test.yml - [`86d4dad`](https://github.com/colinhacks/zod/commit/86d4dad5bc27b4b35df533c9170a552ad8c6c3bc) Fix partial record - [`5e6c0fd`](https://github.com/colinhacks/zod/commit/5e6c0fd7471636feffe5763c9b7637879da459fe) Fix attw on windows - [`27fc616`](https://github.com/colinhacks/zod/commit/27fc616b8edb93cc27a4d25b37479d6e418bbccf) Extend test timeout - [`8d336c4`](https://github.com/colinhacks/zod/commit/8d336c4d15e1917d78b67b890f7182f26633b56f) Remove windows runner - [`5be72e0`](https://github.com/colinhacks/zod/commit/5be72e0ef4dceb1387febb7981079ecdeb5e2817) chore(doc): update metadata.tsx ([#&#8203;5331](https://github.com/colinhacks/zod/issues/5331)) - [`cb0272a`](https://github.com/colinhacks/zod/commit/cb0272a0ad9962df95832a78587f54afec685351) docs: add 'cd zod' step to development setup instructions ([#&#8203;5394](https://github.com/colinhacks/zod/issues/5394)) - [`24e3325`](https://github.com/colinhacks/zod/commit/24e3325dc63010e4f74e23caf91199652e8b12a9) docs: replace 'Refinement' with 'Transform' in transforms section ([#&#8203;5397](https://github.com/colinhacks/zod/issues/5397)) - [`644a082`](https://github.com/colinhacks/zod/commit/644a08203ebb00e23484b3f9a986ae783ce26a9a) chore: add resource for validating environment variables with Zod ([#&#8203;5403](https://github.com/colinhacks/zod/issues/5403)) - [`5e1cfcf`](https://github.com/colinhacks/zod/commit/5e1cfcf578a47527044e85455e79c907fd913adc) Change doc for email validation method in Zod schema ([#&#8203;5392](https://github.com/colinhacks/zod/issues/5392)) - [`88cf944`](https://github.com/colinhacks/zod/commit/88cf9441448608d9de24b47b8a4a4ba879fc2433) Fix: Iterate over keys in catchall object using "in" operator. ([#&#8203;5376](https://github.com/colinhacks/zod/issues/5376)) - [`aa43732`](https://github.com/colinhacks/zod/commit/aa437325c5957c0cf57667cd7b8568603ee7ecd3) Emphasise that `enum` validates against values, for object literal & `enum`s ([#&#8203;5386](https://github.com/colinhacks/zod/issues/5386)) - [`3a4bd00`](https://github.com/colinhacks/zod/commit/3a4bd00aaa16276ffeb2708cc083a633bd4dd756) Improve Hebrew localization for Zod error messages ([#&#8203;5409](https://github.com/colinhacks/zod/issues/5409)) - [`c10f9d1`](https://github.com/colinhacks/zod/commit/c10f9d109874aeca6855383616c086b077d39f89) Fix typos ([#&#8203;5420](https://github.com/colinhacks/zod/issues/5420)) - [`86f0ef9`](https://github.com/colinhacks/zod/commit/86f0ef918bb24f4ab9f1ce2afc5cf2d1a4a99473) Documentation Improvements ([#&#8203;5417](https://github.com/colinhacks/zod/issues/5417)) - [`e120a48`](https://github.com/colinhacks/zod/commit/e120a4877f4d8d076abf2db5c5cceab91a046be9) Fix opt tuple - [`f9bbb50`](https://github.com/colinhacks/zod/commit/f9bbb50c48f9c07ca869d28d6a7086d7290b97a3) Improve tuple - [`0ba0f34`](https://github.com/colinhacks/zod/commit/0ba0f348f677688b69ed78473e022f5d225b41fc) Optimize docs caching/ISR ([#&#8203;5433](https://github.com/colinhacks/zod/issues/5433)) - [`c3ec66c`](https://github.com/colinhacks/zod/commit/c3ec66c74b3fbc2616e880a90751c2cad7270bb3) Improve docs caching - [`c8cce4b`](https://github.com/colinhacks/zod/commit/c8cce4b607a7c0ca99cfb454571a3948ee9e85fb) docs: fix typos and links ([#&#8203;5428](https://github.com/colinhacks/zod/issues/5428)) - [`84ec047`](https://github.com/colinhacks/zod/commit/84ec04708525d6e83e3408d5d3a21edde742bdc5) docs(ecosystem): Add react-f3 ([#&#8203;5429](https://github.com/colinhacks/zod/issues/5429)) - [`3396515`](https://github.com/colinhacks/zod/commit/3396515cc6f04f5f346a1e00256ad09998dbaeb3) Docs: Fix typo in safeExtend description ([#&#8203;5445](https://github.com/colinhacks/zod/issues/5445)) - [`3d93a7d`](https://github.com/colinhacks/zod/commit/3d93a7d593c19dc1822bc96a7c9d47312c29995e) feat: MAC address validation in v4 and mini ([#&#8203;5440](https://github.com/colinhacks/zod/issues/5440)) - [`f2f0d17`](https://github.com/colinhacks/zod/commit/f2f0d178e1c526bc00ad0385706efad318bd44b0) Fix dual package hazard for `globalRegistry` ([#&#8203;5452](https://github.com/colinhacks/zod/issues/5452)) - [`9fc493f`](https://github.com/colinhacks/zod/commit/9fc493f86f17a5fc550df78e7e261137885f51ea) fix: use oneOf for discriminated unions in JSON Schema ([#&#8203;5453](https://github.com/colinhacks/zod/issues/5453)) - [`603dbe8`](https://github.com/colinhacks/zod/commit/603dbe8dba6253c702ca8cf10b5299910dba3c88) Clean up regex, drop backreferences - [`ab69b9e`](https://github.com/colinhacks/zod/commit/ab69b9ee813713a111b56a60c2df929eaf5ba426) Update mac addr tests - [`f791052`](https://github.com/colinhacks/zod/commit/f7910528901c05293bad275fffcb54a82e28fcc9) chore: upgrade vitest to v4 ([#&#8203;5028](https://github.com/colinhacks/zod/issues/5028)) - [`f97e80d`](https://github.com/colinhacks/zod/commit/f97e80da9197064937a58167619967bee4ebb638) fix(core): prevent infinite recursion for recursive tuples ([#&#8203;5089](https://github.com/colinhacks/zod/issues/5089)) ([#&#8203;5094](https://github.com/colinhacks/zod/issues/5094)) - [`002e01a`](https://github.com/colinhacks/zod/commit/002e01ad0fcc17b17683adafc80f2a86e8d355a9) fix(record): handle non-function constructor field in isPlainObject ([#&#8203;5098](https://github.com/colinhacks/zod/issues/5098)) - [`6716517`](https://github.com/colinhacks/zod/commit/67165174eb8c7d5c6e76e760830f3109b4fdbd0e) docs(contributing): add instructions on building [@&#8203;zod/docs](https://github.com/zod/docs) ([#&#8203;5114](https://github.com/colinhacks/zod/issues/5114)) - [`8b0603d`](https://github.com/colinhacks/zod/commit/8b0603dde684f1665bb2329111ed187f73ccf0ac) Fix typo in ISO time documentation ([#&#8203;5277](https://github.com/colinhacks/zod/issues/5277)) - [`be85ecc`](https://github.com/colinhacks/zod/commit/be85ecc48a83e7f65ac0458d25f832fb4e28c9e7) docs(codecs): correct `stringToDate` safeDecode methods ([#&#8203;5302](https://github.com/colinhacks/zod/issues/5302)) - [`50bba54`](https://github.com/colinhacks/zod/commit/50bba5462546401939920a6566a81c0d9c8ef7e1) Add zodgres to ecosystem documentation ([#&#8203;5308](https://github.com/colinhacks/zod/issues/5308)) - [`377f5d1`](https://github.com/colinhacks/zod/commit/377f5d1eb05bfa2631ac1f020d118f5d3ca99c94) Add `zod-to-mongo-schema` to ecosystem documentation ([#&#8203;5457](https://github.com/colinhacks/zod/issues/5457)) - [`dea32d5`](https://github.com/colinhacks/zod/commit/dea32d52a5745eb6ed9aee2ecab4b01f4ccd0313) docs(ecosystem): add fn sphere and zod-compare ([#&#8203;5326](https://github.com/colinhacks/zod/issues/5326)) - [`02ea4c8`](https://github.com/colinhacks/zod/commit/02ea4c82ff3e71f39deaa14159f7ce486b337aa0) Add Claude Code GitHub Workflow ([#&#8203;5460](https://github.com/colinhacks/zod/issues/5460)) - [`d44253d`](https://github.com/colinhacks/zod/commit/d44253d6498564ecd24a6248ddca4e9bf4e43058) Add support for number literal and TypeScript's enum keys in `z.record` ([#&#8203;5334](https://github.com/colinhacks/zod/issues/5334)) - [`f52344e`](https://github.com/colinhacks/zod/commit/f52344e76bed0e69175ca8893c84736cf97b5d11) Fix vitest 4 - [`0f4ce73`](https://github.com/colinhacks/zod/commit/0f4ce73ad0c5610c3c53857d05ebae619d229aa3) Do not allow unsound pick/omit - [`162fe29`](https://github.com/colinhacks/zod/commit/162fe298f0ec76d7f7883afbebdd732eb3c60773) Add z.meta and z.describe - [`3de39ee`](https://github.com/colinhacks/zod/commit/3de39eea6f7ed286ae182093d0c91f3a6fdcca06) Implement slugify - [`5bfc8f2`](https://github.com/colinhacks/zod/commit/5bfc8f269a81d9edc283e7920868161e4129fb23) Fix docs - [`0e803a2`](https://github.com/colinhacks/zod/commit/0e803a29344a2f0ee637940cca96be3e6978b22e) Revert "Do not allow unsound pick/omit" - [`a774750`](https://github.com/colinhacks/zod/commit/a774750d113982da28a2768b0a7c2de1f20c04e8) v4.1.13 - [`2cdd82b`](https://github.com/colinhacks/zod/commit/2cdd82b663706fdf642d7f030841a5b278f9173c) 4.1.13 - [`4063e80`](https://github.com/colinhacks/zod/commit/4063e802d539d04182fc3e66a543ae6d1ba5658e) Update check-semver script ### [`v4.1.12`](https://github.com/colinhacks/zod/releases/tag/v4.1.12) [Compare Source](https://github.com/colinhacks/zod/compare/v4.1.11...v4.1.12) #### Commits: - [`0b109c3`](https://github.com/colinhacks/zod/commit/0b109c37c6b0b10e3901b56bcccb72e29a0b846f) docs(ecosystem): add bupkis to the ecosystem section ([#&#8203;5237](https://github.com/colinhacks/zod/issues/5237)) - [`d22ec0d`](https://github.com/colinhacks/zod/commit/d22ec0d26fab27151b0f1d1f98bffeaf8b011f57) docs(ecosystem): add upfetch ([#&#8203;5238](https://github.com/colinhacks/zod/issues/5238)) - [`c56a4f6`](https://github.com/colinhacks/zod/commit/c56a4f6fab42c542b191228af61974b2328dc52f) docs(ecosystem): add `eslint-plugin-zod-x` ([#&#8203;5261](https://github.com/colinhacks/zod/issues/5261)) - [`a0abcc0`](https://github.com/colinhacks/zod/commit/a0abcc02900a4293dd4f30cd81580efcdd5230bb) docs(metadata.mdx): fix a mistake in an example output ([#&#8203;5248](https://github.com/colinhacks/zod/issues/5248)) - [`62bf4e4`](https://github.com/colinhacks/zod/commit/62bf4e439e287e55c843245b49f8d34b1ad024ee) fix(ZodError): prevent flatten() from crashing on 'toString' key ([#&#8203;5266](https://github.com/colinhacks/zod/issues/5266)) - [`02a5840`](https://github.com/colinhacks/zod/commit/02a584010ac92ac8a351632ae5aea3983a6f17d8) refac(errors): Unify code structure and improve types ([#&#8203;5278](https://github.com/colinhacks/zod/issues/5278)) - [`4b1922a`](https://github.com/colinhacks/zod/commit/4b1922ad714e12dafaa83a40ec03275a39ac980c) docs(content/v4/index): fix zod version ([#&#8203;5289](https://github.com/colinhacks/zod/issues/5289)) - [`3fcb20f`](https://github.com/colinhacks/zod/commit/3fcb20ff348e49aec70f45e0dca3de8a61450e77) Add frrm to ecosystem ([#&#8203;5292](https://github.com/colinhacks/zod/issues/5292)) - [`fda4c7c`](https://github.com/colinhacks/zod/commit/fda4c7c2afbd7649261be1e7954f8c4d4de24a07) Make docs work without token - [`af44738`](https://github.com/colinhacks/zod/commit/af447384379faef28aa857fb53ef1da702c6d408) Fix lint - [`77c3c9f`](https://github.com/colinhacks/zod/commit/77c3c9f069a4cf168c0cbc58432803de887a6b1b) Export bg.ts - [`3b94610`](https://github.com/colinhacks/zod/commit/3b946107b6c94b2ac8ff9fb451160c34dc4dd794) v4.1.12 ### [`v4.1.11`](https://github.com/colinhacks/zod/releases/tag/v4.1.11) [Compare Source](https://github.com/colinhacks/zod/compare/v4.1.10...v4.1.11) #### Commits: - [`2bed4b3`](https://github.com/colinhacks/zod/commit/2bed4b39760d8e4d678203b5c8fcaf24c182fc9f) 4.1.11 ### [`v4.1.10`](https://github.com/colinhacks/zod/releases/tag/v4.1.10) [Compare Source](https://github.com/colinhacks/zod/compare/v4.1.9...v4.1.10) #### Commits: - [`7ffedd0`](https://github.com/colinhacks/zod/commit/7ffedd00169d8dc2e7cb7c6d878f29b03e05b3a3) Fix shape caching ([#&#8203;5263](https://github.com/colinhacks/zod/issues/5263)) - [`82cd717`](https://github.com/colinhacks/zod/commit/82cd717a0e7ee4e1737a783c7be278fa93fd8104) v4.1.10 ### [`v4.1.9`](https://github.com/colinhacks/zod/releases/tag/v4.1.9) [Compare Source](https://github.com/colinhacks/zod/compare/v4.1.8...v4.1.9) #### Commits: - [`a78716d`](https://github.com/colinhacks/zod/commit/a78716d91da7649a61016b81c27f49fd9e79a81e) Update zshy ([#&#8203;5249](https://github.com/colinhacks/zod/issues/5249)) - [`923af80`](https://github.com/colinhacks/zod/commit/923af801fde9f033cfd7e0e753b421a554fe3be8) Publish zod\@&#8203;4.1.9 ### [`v4.1.8`](https://github.com/colinhacks/zod/releases/tag/v4.1.8) [Compare Source](https://github.com/colinhacks/zod/compare/v4.1.7...v4.1.8) #### Commits: - [`36c4ee3`](https://github.com/colinhacks/zod/commit/36c4ee354d0c1f47b7311e49f6dd4b7a11de04f5) Switch back to weakmap - [`a1726d5`](https://github.com/colinhacks/zod/commit/a1726d53172ba52ecf90999df73778cf416264fd) 4.1.8 ### [`v4.1.7`](https://github.com/colinhacks/zod/releases/tag/v4.1.7) [Compare Source](https://github.com/colinhacks/zod/compare/976b43657d4aff6d47c73c1c86125623ea08752d...v4.1.7) #### Commits: - [`0cca351`](https://github.com/colinhacks/zod/commit/0cca351c8b152d7c4113ab7c2a44675efb060677) Fix variable name inconsistency in coercion documentation ([#&#8203;5188](https://github.com/colinhacks/zod/issues/5188)) - [`aa78c27`](https://github.com/colinhacks/zod/commit/aa78c270f1b43f4665339f4b61e7cb88037b8c84) Add copy/edit buttons - [`76452d4`](https://github.com/colinhacks/zod/commit/76452d4119d800a722b692755c1168627bc95f0f) Update button txt - [`937f73c`](https://github.com/colinhacks/zod/commit/937f73c90cac90bd3b99b12c792c289b50416510) Fix tsconfig issue in bench - [`976b436`](https://github.com/colinhacks/zod/commit/976b43657d4aff6d47c73c1c86125623ea08752d) v4.1.6 ([#&#8203;5222](https://github.com/colinhacks/zod/issues/5222)) - [`4309c61`](https://github.com/colinhacks/zod/commit/4309c61304daf40aab2124b5f513abe2b4df8637) Fix cidrv6 validation - cidrv6 should reject invalid strings with multiple slashes ([#&#8203;5196](https://github.com/colinhacks/zod/issues/5196)) - [`ef95a73`](https://github.com/colinhacks/zod/commit/ef95a73b6d33299743e5ff4f0645b98c1b0d6f72) feat(locales): Add Lithuanian (lt) locale ([#&#8203;5210](https://github.com/colinhacks/zod/issues/5210)) - [`3803f3f`](https://github.com/colinhacks/zod/commit/3803f3f37168212f2178e8b8deceb7bad78ed904) docs: update wrong contents in codeblocks in `api.mdx` ([#&#8203;5209](https://github.com/colinhacks/zod/issues/5209)) - [`8a47d5c`](https://github.com/colinhacks/zod/commit/8a47d5c6ba8e4fe2f934a8e55d0cba4d81d821de) docs: update coerce example in `api.mdx` ([#&#8203;5207](https://github.com/colinhacks/zod/issues/5207)) - [`e87db13`](https://github.com/colinhacks/zod/commit/e87db1322f11ff6907e1789da28933d258ab75fd) feat(locales): Add Georgian (ka) locale ([#&#8203;5203](https://github.com/colinhacks/zod/issues/5203)) - [`c54b123`](https://github.com/colinhacks/zod/commit/c54b123e399a6ab266504eb1389c724af31d5998) docs: adds `@traversable/zod` and `@traversable/zod-test` to v4 ecosystem ([#&#8203;5194](https://github.com/colinhacks/zod/issues/5194)) - [`c27a294`](https://github.com/colinhacks/zod/commit/c27a294f5b792f47b8e9dbb293a8ff8cfb287a3a) Fix two tiny grammatical errors in the docs. ([#&#8203;5193](https://github.com/colinhacks/zod/issues/5193)) - [`23a2d66`](https://github.com/colinhacks/zod/commit/23a2d6692398e3dd1ad1cdb0491b271a9f989380) docs: fix broken links in async refinements and transforms references ([#&#8203;5190](https://github.com/colinhacks/zod/issues/5190)) - [`845a230`](https://github.com/colinhacks/zod/commit/845a230bb06bff679b5f00e10153f4dbbd50d2b6) fix(locales): Add type name translations to Spanish locale ([#&#8203;5187](https://github.com/colinhacks/zod/issues/5187)) - [`27f13d6`](https://github.com/colinhacks/zod/commit/27f13d62b98cf5c501b828ba8837ff73cd6263d2) Improve regex precision and eliminate duplicates in regexes.ts ([#&#8203;5181](https://github.com/colinhacks/zod/issues/5181)) - [`a8a52b3`](https://github.com/colinhacks/zod/commit/a8a52b3ba370b761be76953fa3986aa43c4172a4) fix(v4): fix Khmer and Ukrainian locales ([#&#8203;5177](https://github.com/colinhacks/zod/issues/5177)) - [`887e37c`](https://github.com/colinhacks/zod/commit/887e37cd7568219c54f9c2f71bbfe0300ce48376) Update slugs - [`e1f1948`](https://github.com/colinhacks/zod/commit/e1f19482bbed3fbaa563a0d8e09f1a577cc58ac7) fix(v4): ensure array defaults are shallow-cloned ([#&#8203;5173](https://github.com/colinhacks/zod/issues/5173)) - [`9f65038`](https://github.com/colinhacks/zod/commit/9f650385644ae319f806a965b83f79ebd252e497) docs(ecosystem): add DRZL; fix Prisma Zod Generator placement ([#&#8203;5215](https://github.com/colinhacks/zod/issues/5215)) - [`aa6f0f0`](https://github.com/colinhacks/zod/commit/aa6f0f02c2a92a266ff1495a8d2541ae46012fcb) More fixes ([#&#8203;5223](https://github.com/colinhacks/zod/issues/5223)) - [`aab3356`](https://github.com/colinhacks/zod/commit/aab33566bdb44a651cc3e27fde729285e4312419) 4.1.7 ### [`v4.1.6`](https://github.com/colinhacks/zod/compare/v4.1.5...976b43657d4aff6d47c73c1c86125623ea08752d) [Compare Source](https://github.com/colinhacks/zod/compare/v4.1.5...976b43657d4aff6d47c73c1c86125623ea08752d) ### [`v4.1.5`](https://github.com/colinhacks/zod/releases/tag/v4.1.5) [Compare Source](https://github.com/colinhacks/zod/compare/v4.1.4...v4.1.5) #### Commits: - [`530415f`](https://github.com/colinhacks/zod/commit/530415f927a8f7fa474c96b667efdad6e771ce4d) Update docs - [`b7b081d`](https://github.com/colinhacks/zod/commit/b7b081d5cfd6fc19aeb71f9dc1b07bb333c37f9d) Update z.function() type to support array input ([#&#8203;5170](https://github.com/colinhacks/zod/issues/5170)) - [`780cf57`](https://github.com/colinhacks/zod/commit/780cf57167cbf3902efab68f19fa21ca09cb9dd6) 4.1.5 ### [`v4.1.4`](https://github.com/colinhacks/zod/releases/tag/v4.1.4) [Compare Source](https://github.com/colinhacks/zod/compare/v4.1.3...v4.1.4) #### Commits: - [`3291c61`](https://github.com/colinhacks/zod/commit/3291c61fe4bc893901027ea5d50dfc6274e49caa) fix(v4): toJSONSchema - wrong tuple with `null` output when targeting `openapi-3.0` ([#&#8203;5156](https://github.com/colinhacks/zod/issues/5156)) - [`23f41c7`](https://github.com/colinhacks/zod/commit/23f41c7e0af107026bb1732af6b4c368d82be8d2) test(v4): toJSONSchema - use `validateOpenAPI30Schema` in all relevant scenarios ([#&#8203;5163](https://github.com/colinhacks/zod/issues/5163)) - [`0a09fd2`](https://github.com/colinhacks/zod/commit/0a09fd21336202e50565a3e22baaab9a7047fcc9) Update installation instructions - [`4ea5fec`](https://github.com/colinhacks/zod/commit/4ea5fec6988eb7260bc63e0eb8b4a6a0b238c414) 4.1.4 ### [`v4.1.3`](https://github.com/colinhacks/zod/releases/tag/v4.1.3) [Compare Source](https://github.com/colinhacks/zod/compare/v4.1.2...v4.1.3) #### Commits: - [`98ff675`](https://github.com/colinhacks/zod/commit/98ff675c313c15d3fa18b2bd01f844b1e817ee79) Drop stringToBoolean - [`a410616`](https://github.com/colinhacks/zod/commit/a410616b39eedf3b4654c0c791b0ab1868996bfb) Fix typo - [`0cf4589`](https://github.com/colinhacks/zod/commit/0cf45896edf8728b57c8e7f2b5a56536760afac1) fix(v4): toJSONSchema - add missing oneOf inside items in tuple conversion ([#&#8203;5146](https://github.com/colinhacks/zod/issues/5146)) - [`8bf0c16`](https://github.com/colinhacks/zod/commit/8bf0c1639f0d3700f01fa8aaee2d8fa5d0abbe10) fix(v4): toJSONSchema tuple path handling for draft-7 with metadata IDs ([#&#8203;5152](https://github.com/colinhacks/zod/issues/5152)) - [`5c5fa90`](https://github.com/colinhacks/zod/commit/5c5fa90e47df934acf6051a3ec30516baeef2eac) fix(v4): toJSONSchema - wrong record output when targeting `openapi-3.0` ([#&#8203;5141](https://github.com/colinhacks/zod/issues/5141)) - [`87b97cc`](https://github.com/colinhacks/zod/commit/87b97ccd556e6d8dc6b4f4455762cc7405b0abc9) docs(codecs): update example to use payloadSchema ([#&#8203;5150](https://github.com/colinhacks/zod/issues/5150)) - [`309f358`](https://github.com/colinhacks/zod/commit/309f3584fd9a3856c3e0c813196210ba4b11d2a9) fix(v4): toJSONSchema - output numbers with exclusive range correctly when targeting `openapi-3.0` ([#&#8203;5139](https://github.com/colinhacks/zod/issues/5139)) - [`1e71ca9`](https://github.com/colinhacks/zod/commit/1e71ca99b92b94aac8ca45694f28864ae1654135) docs: fix refine fn to encode works properly ([#&#8203;5148](https://github.com/colinhacks/zod/issues/5148)) - [`a85ec3c`](https://github.com/colinhacks/zod/commit/a85ec3c73c6a98a496f5dd3b6fb19ebe07e227f9) fix(docs): correct example to use `LooseDog` instead of `Dog` ([#&#8203;5136](https://github.com/colinhacks/zod/issues/5136)) - [`3e98274`](https://github.com/colinhacks/zod/commit/3e982743f3abba6a421abb899670f70e49284af4) 4.1.3 ### [`v4.1.2`](https://github.com/colinhacks/zod/releases/tag/v4.1.2) [Compare Source](https://github.com/colinhacks/zod/compare/v4.1.1...v4.1.2) #### Commits: - [`e45e61b`](https://github.com/colinhacks/zod/commit/e45e61b675baf055f4a3ef2ddead21715a1e4fe3) Improve codec docs - [`25a4c37`](https://github.com/colinhacks/zod/commit/25a4c376834db90d3bb3e70d4154e3eb6d4feb7a) fix(v4): toJSONSchema - wrong record tuple output when targeting `openapi-3.0` ([#&#8203;5145](https://github.com/colinhacks/zod/issues/5145)) - [`0fa4f46`](https://github.com/colinhacks/zod/commit/0fa4f464e0e679d71b183e8811ef1e4f30aaa06a) Use method form in codecs.mdx - [`940383d`](https://github.com/colinhacks/zod/commit/940383d0523da41c4e2422b76455da39dddd6c4f) Update JSON codec and docs - [`3009fa8`](https://github.com/colinhacks/zod/commit/3009fa8aeb90e00bfc35c7124f3e6f8cad11d290) 4.1.2 ### [`v4.1.1`](https://github.com/colinhacks/zod/releases/tag/v4.1.1) [Compare Source](https://github.com/colinhacks/zod/compare/v4.1.0...v4.1.1) #### Commits: - [`648eb43`](https://github.com/colinhacks/zod/commit/648eb43c23e31f7d69ef09baba46aef4e9493b13) Remove codecs from sidebare - [`7e39a99`](https://github.com/colinhacks/zod/commit/7e39a99a88a9b7f0c9c3d5fd40fbbab494365c9a) Improve codec docs - [`e5085be`](https://github.com/colinhacks/zod/commit/e5085beb2653f1d05a14c07c79b6f3707daf09f6) Add images - [`028b289`](https://github.com/colinhacks/zod/commit/028b289a48f5589dca58b0b813a5a9f9e363a40b) Add methods - [`10cc994`](https://github.com/colinhacks/zod/commit/10cc9941daeb28b6be5be7327e034c3388d8e60b) 4.1.1 ### [`v4.1.0`](https://github.com/colinhacks/zod/releases/tag/v4.1.0) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.17...v4.1.0) The first minor version since the introduction of Zod 4 back in May. This version contains a number of features that barely missed the cut for the 4.0 release. With Zod 4 stable and widely adopted, there's more time to resume feature development. #### Codecs This is the flagship feature of this release. Codecs are a new API & schema type that encapsulates a *bi-directional transformation*. It's a huge missing piece in Zod that's finally filled, and it unlocks some totally new ways to use Zod. ```ts const stringToDate = z.codec( z.iso.datetime(), // input schema: ISO date string z.date(), // output schema: Date object { decode: (isoString) => new Date(isoString), encode: (date) => date.toISOString(), } ); ``` New top-level functions are added for processing inputs in the *forward* direction ("decoding") and *backward* direction ("encoding"). ```ts stringToDate.decode("2025-08-21T20:59:45.500Z") // => Date stringToDate.encode(new Date()) // => "2025-08-21T20:59:45.500Z" ``` > **Note** — For bundle size reasons, these new methods have not added to Zod Mini schemas. Instead, this functionality is available via equivalent top-level functions. > > ```ts > // equivalent at runtime > z.decode(stringToDate, "2024-01-15T10:30:00.000Z"); > z.encode(stringToDate, new Date()); > ``` ##### `.parse()` vs `.decode()` Both `.parse()` and `decode()` process data in the "forward" direction. They behave identically at runtime. ```ts stringToDate.parse("2025-08-21T20:59:45.500Z"); stringToDate.decode("2025-08-21T20:59:45.500Z"); ``` There is an important difference however. While `.parse()` accepts any input, `.decode()` expects a *strongly typed* input. That is, it expects an input of type `string`, whereas `.parse()` accepts `unknown`. ```ts stringToDate.parse(Symbol('not-a-string')); // => fails at runtime, but no TypeScript error stringToDate.decode(Symbol("not-a-string")); // ^ ❌ Argument of type 'symbol' is not assignable to parameter of type 'Date'. ts(2345) ``` > This is a highly requested feature unto itself: > > - [#&#8203;3860](https://github.com/colinhacks/zod/issues/3860) > - [#&#8203;1748](https://github.com/colinhacks/zod/issues/1748) > - [#&#8203;3978](https://github.com/colinhacks/zod/issues/3978) > - [#&#8203;1892](https://github.com/colinhacks/zod/issues/1892) ##### Encoding You can use any Zod schema with `.encode()`. The vast majority of Zod schemas are *non-transforming* (the input and output types are identical) so `.decode()` and `.encode()` behave identically. Only certain schema types change their behavior: - **Codecs** — runs from `B->A` and executes the `encode` transform during encoding - **Pipes** — these execute `B->A` instead of `A->B` - **Defaults and prefaults** — Only applied in the forward direction - **Catch** — Only applied in the forward direction > **Note** — To avoid increasing bundle size unnecessarily, these new methods are not available on Zod Mini schemas. For those schemas, equivalent top-level functions are provided. The usual *async* and *safe* variants exist as well: ```ts // decode methods stringToDate.decode("2024-01-15T10:30:00.000Z") await stringToDate.decodeAsync("2024-01-15T10:30:00.000Z") stringToDate.safeDecode("2024-01-15T10:30:00.000Z") await stringToDate.safeDecodeAsync("2024-01-15T10:30:00.000Z") // encode methods stringToDate.encode(new Date()) await stringToDate.encodeAsync(new Date()) stringToDate.safeEncode(new Date()) await stringToDate.safeEncodeAsync(new Date()) ``` ##### Example codecs Below are some "worked examples" for some commonly-needed codecs. These examples are all tested internally for correctness. Just copy/paste them into your project as needed. There is a more comprehensive set available at [zod.dev/codecs](https://zod.dev/codecs). ##### `stringToBigInt` Converts `bigint` into a serializable form. ``` const stringToBigInt = z.codec(z.string(), z.bigint(), { decode: (str) => BigInt(str), encode: (bigint) => bigint.toString(), }); stringToBigInt.decode("12345"); // => 12345n stringToBigInt.encode(12345n); // => "12345" ``` ##### `json` Parses/stringifies JSON data. ```ts const jsonCodec = z.codec(z.string(), z.json(), { decode: (jsonString, ctx) => { try { return JSON.parse(jsonString); } catch (err: any) { ctx.issues.push({ code: "invalid_format", format: "json_string", input: jsonString, message: err.message, }); return z.NEVER; } }, encode: (value) => JSON.stringify(value), }); ``` To further validate the data, `.pipe()` the result of this codec into another schema. ```ts const Params = z.object({ name: z.string(), age: z.number() }); const JsonToParams = jsonCodec.pipe(Params); JsonToParams.decode('{"name":"Alice","age":30}'); // => { name: "Alice", age: 30 } JsonToParams.encode({ name: "Bob", age: 25 }); // => '{"name":"Bob","age":25}' ``` ##### Further reading **For more examples and a technical breakdown of how encoding works, reads the[announcement blog post](https://colinhacks.com/essays/introducing-zod-codecs) and [new Codecs docs page](https://zod.dev/codecs)**. The docs page contains implementations for several other commonly-needed codecs: - [`stringToNumber`](https://zod.dev/codecs?id=stringtonumber) - [`stringToInt`](https://zod.dev/codecs?id=stringtoint) - [`stringToBigInt`](https://zod.dev/codecs?id=stringtobigint) - [`numberToBigInt`](https://zod.dev/codecs?id=numbertobigint) - [`isoDatetimeToDate`](https://zod.dev/codecs?id=isodatetimetodate) - [`epochSecondsToDate`](https://zod.dev/codecs?id=epochsecondstodate) - [`epochMillisToDate`](https://zod.dev/codecs?id=epochmillistodate) - [`jsonCodec`](https://zod.dev/codecs?id=jsoncodec) - [`utf8ToBytes`](https://zod.dev/codecs?id=utf8tobytes) - [`bytesToUtf8`](https://zod.dev/codecs?id=bytestoutf8) - [`base64ToBytes`](https://zod.dev/codecs?id=base64tobytes) - [`base64urlToBytes`](https://zod.dev/codecs?id=base64urltobytes) - [`hexToBytes`](https://zod.dev/codecs?id=hextobytes) - [`stringToURL`](https://zod.dev/codecs?id=stringtourl) - [`stringToHttpURL`](https://zod.dev/codecs?id=stringtohttpurl) - [`uriComponent`](https://zod.dev/codecs?id=uricomponent) - [`stringToBoolean`](https://zod.dev/codecs?id=stringtoboolean) #### `.safeExtend()` The existing way to add additional fields to an object is to use `.extend()`. ```ts const A = z.object({ a: z.string() }) const B = A.extend({ b: z.string() }) ``` Unfortunately this is a bit of a misnomer, as it allows you to overwrite existing fields. This means the result of `.extend()` may not literally `extend` the original type (in the TypeScript sense). ```ts const A = z.object({ a: z.string() }) // { a: string } const B = A.extend({ a: z.number() }) // { a: number } ``` To enforce true `extends` logic, Zod 4.1 introduces a new `.safeExtend()` method. This statically enforces that the newly added properties conform to the existing ones. ```ts z.object({ a: z.string() }).safeExtend({ a: z.number().min(5) }); // ✅ z.object({ a: z.string() }).safeExtend({ a: z.any() }); // ✅ z.object({ a: z.string() }).safeExtend({ a: z.number() }); // ^ ❌ ZodNumber is not assignable ``` Importantly, this new API allows you to safely extend objects containing refinements. ```ts const AB = z.object({ a: z.string(), b: z.string() }).refine(val => val.a === val.b); const ABC = AB.safeExtend({ c: z.string() }); // ABC includes the refinements defined on AB ``` Previously (in Zod 4.x) any refinements attached to the base schema were dropped in the extended result. This was too unexpected. It now throws an error. (Zod 3 did not support extension of refined objects either.) #### `z.hash()` A new top-level string format for validating hashes produced using various common algorithms & encodings. ```ts const md5Schema = z.hash("md5"); // => ZodCustomStringFormat<"md5_hex"> const sha256Base64 = z.hash("sha256", { enc: "base64" }); // => ZodCustomStringFormat<"sha256_base64"> ``` The following hash algorithms and encodings are supported. Each cell provides information about the expected number of characters/padding. | Algorithm / Encoding | `"hex"` | `"base64"` | `"base64url"` | | -------------------- | ------- | --------------- | ------------- | | `"md5"` | 32 | 24 (22 + "==") | 22 | | `"sha1"` | 40 | 28 (27 + "=") | 27 | | `"sha256"` | 64 | 44 (43 + "=") | 43 | | `"sha384"` | 96 | 64 (no padding) | 64 | | `"sha512"` | 128 | 88 (86 + "==") | 86 | #### `z.hex()` To validate hexadecimal strings of any length. ```ts const hexSchema = z.hex(); hexSchema.parse("123abc"); // ✅ "123abc" hexSchema.parse("DEADBEEF"); // ✅ "DEADBEEF" hexSchema.parse("xyz"); // ❌ ZodError ``` #### Additional changes 1. **z.uuid()** now supports the "Max UUID" (`FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF`) per the [RFC](https://www.rfc-editor.org/rfc/rfc9562.html) 2. `$ZodFunction` is now a subtype of `$ZodType` *** #### Commits - [`edd4fea`](https://github.com/colinhacks/zod/commit/edd4feaa) - Closes [#&#8203;5127](https://github.com/colinhacks/zod/issues/5127) - [`5d4a315`](https://github.com/colinhacks/zod/commit/5d4a3159) - Closes [#&#8203;5116](https://github.com/colinhacks/zod/issues/5116) - [`f3f0955`](https://github.com/colinhacks/zod/commit/f3f09556) - Closes [#&#8203;5108](https://github.com/colinhacks/zod/issues/5108) - [`0114d5b`](https://github.com/colinhacks/zod/commit/0114d5bd) - [#&#8203;5122](https://github.com/colinhacks/zod/issues/5122) - [`3b077c3`](https://github.com/colinhacks/zod/commit/3b077c3a) - [#&#8203;5121](https://github.com/colinhacks/zod/issues/5121) - [`1e06af8`](https://github.com/colinhacks/zod/commit/1e06af8e) - [#&#8203;5113](https://github.com/colinhacks/zod/issues/5113) - [`b01b6f3`](https://github.com/colinhacks/zod/commit/b01b6f39) — [#&#8203;5052](https://github.com/colinhacks/zod/issues/5052) - [`571ab0c`](https://github.com/colinhacks/zod/commit/571ab0c3) — [#&#8203;5051](https://github.com/colinhacks/zod/issues/5051) - [`d3ea111`](https://github.com/colinhacks/zod/commit/d3ea1119) — [#&#8203;5049](https://github.com/colinhacks/zod/issues/5049) - [`b8e3f87`](https://github.com/colinhacks/zod/commit/b8e3f877) — [#&#8203;4865](https://github.com/colinhacks/zod/issues/4865) ### [`v4.0.17`](https://github.com/colinhacks/zod/releases/tag/v4.0.17) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.16...v4.0.17) #### Commits: - [`1cebf33`](https://github.com/colinhacks/zod/commit/1cebf336c560c87e6f806b9d02106fb623049f21) Add blog ([#&#8203;5074](https://github.com/colinhacks/zod/issues/5074)) - [`fc1e556`](https://github.com/colinhacks/zod/commit/fc1e556318159b4740ba3d6b37660e783d2a3cb7) Fixes [#&#8203;5073](https://github.com/colinhacks/zod/issues/5073) - [`cc63f95`](https://github.com/colinhacks/zod/commit/cc63f950158db212c5e9b75e7d22faca851ea624) v4.0.17 ### [`v4.0.16`](https://github.com/colinhacks/zod/releases/tag/v4.0.16) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.15...v4.0.16) #### Commits: - [`d589186`](https://github.com/colinhacks/zod/commit/d589186c20c3dc112f5a5fda23cccd4d1f74420e) fix: ensure keyof returns enum ([#&#8203;5045](https://github.com/colinhacks/zod/issues/5045)) - [`4975f3a`](https://github.com/colinhacks/zod/commit/4975f3a0e9c9f0b241499d936a02f1998c66dc01) feat: add discriminator generic ([#&#8203;5044](https://github.com/colinhacks/zod/issues/5044)) - [`0a463e3`](https://github.com/colinhacks/zod/commit/0a463e38e7f77b8036628ff911de515f9f9f6662) Update speakeasy files - [`12658af`](https://github.com/colinhacks/zod/commit/12658aff60349a87972a782b64802ec901c5ebf2) Fix Edit page buttons - [`47e6604`](https://github.com/colinhacks/zod/commit/47e6604a3555811115d05bf41e50de54192e2e14) fix: `edit this page` button, now redirects to correct url using the new path ([#&#8203;5056](https://github.com/colinhacks/zod/issues/5056)) - [`7207a2d`](https://github.com/colinhacks/zod/commit/7207a2df38caaae910551b7ecf04941b00fc10c8) Update Hey API link to Zod v3 plugin ([#&#8203;5060](https://github.com/colinhacks/zod/issues/5060)) - [`6887ff3`](https://github.com/colinhacks/zod/commit/6887ff34fb9bf5f6769152cf62ba9b69fa378aac) Update Hey API link to Zod plugin ([#&#8203;5059](https://github.com/colinhacks/zod/issues/5059)) - [`ffff1aa`](https://github.com/colinhacks/zod/commit/ffff1aac6a9a88fe6e7ad2659dbc7743275ea052) Clone POJO objects during defaulting/prefaulting - [`a227cb3`](https://github.com/colinhacks/zod/commit/a227cb3bd22aba48412a0129650b86277adc3545) v4.0.16 ### [`v4.0.15`](https://github.com/colinhacks/zod/releases/tag/v4.0.15) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.14...v4.0.15) #### Commits: - [`7e7e346`](https://github.com/colinhacks/zod/commit/7e7e3461aceecf3633e158df50d6bc852e7cdf45) Clean up docs - [`f2949a8`](https://github.com/colinhacks/zod/commit/f2949a81a06fe197c53e47c1fab024cebbd7f1f1) \[docs] Fix migration guide upgrade command ([#&#8203;5021](https://github.com/colinhacks/zod/issues/5021)) - [`d43cf19`](https://github.com/colinhacks/zod/commit/d43cf19d5cafd505f2f8e76f13e18564470f0696) Fix recursive object initialization errors with check() and other methods ([#&#8203;5018](https://github.com/colinhacks/zod/issues/5018)) - [`3de2b63`](https://github.com/colinhacks/zod/commit/3de2b6389a57a093f11ecf1820f31e5b4452c7e9) fix: remove redundant Required<> from input and output type definitions ([#&#8203;5033](https://github.com/colinhacks/zod/issues/5033)) - [`93553bd`](https://github.com/colinhacks/zod/commit/93553bd48aeac27fdeb7dcbee5b7e37628572aff) Add needs info - [`03cfa8d`](https://github.com/colinhacks/zod/commit/03cfa8d9367c56d8c29870a83af10edc91eba34a) 4.0.15 ### [`v4.0.14`](https://github.com/colinhacks/zod/releases/tag/v4.0.14) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.13...v4.0.14) #### Commits: - [`99391a8`](https://github.com/colinhacks/zod/commit/99391a844271558e0f1736c9550375e82e630bbd) Docs: Fix typo ([#&#8203;5005](https://github.com/colinhacks/zod/issues/5005)) - [`e25303e`](https://github.com/colinhacks/zod/commit/e25303e98c8d13ea96c3296507c564011f403ffe) Docs: fix typo ([#&#8203;5008](https://github.com/colinhacks/zod/issues/5008)) - [`dbb05ef`](https://github.com/colinhacks/zod/commit/dbb05ef990c86ec6b1f6eac11b91ec7572e29c89) Add JSON Schema draft-04 output ([#&#8203;4811](https://github.com/colinhacks/zod/issues/4811)) - [`b8257d7`](https://github.com/colinhacks/zod/commit/b8257d7d1f51dd3cb4033a58271bb6ac8e3678c7) Improve tuple recursive inference. - [`9bdbc2f`](https://github.com/colinhacks/zod/commit/9bdbc2f10d466050421a8e28c4b95a8a5776d150) Avoid infinite loops in defineLazy. Fixes [#&#8203;4994](https://github.com/colinhacks/zod/issues/4994). - [`af96ad4`](https://github.com/colinhacks/zod/commit/af96ad4700879b0d6e390a0c65ded4e700049cb9) 4.0.14 ### [`v4.0.13`](https://github.com/colinhacks/zod/releases/tag/v4.0.13) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.12...v4.0.13) #### Commits: - [`362eb33`](https://github.com/colinhacks/zod/commit/362eb33093e9c5f306eeec95e36985a99aba8fc7) Fix optional + pipe handling. Closes [#&#8203;5002](https://github.com/colinhacks/zod/issues/5002). v4.0.13 ### [`v4.0.12`](https://github.com/colinhacks/zod/releases/tag/v4.0.12) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.11...v4.0.12) #### Commits: - [`ff83fc9`](https://github.com/colinhacks/zod/commit/ff83fc916ec2b35c0008a48782fa14f84293149d) Add eslint-plugin-import-zod ([#&#8203;4848](https://github.com/colinhacks/zod/issues/4848)) - [`7c9ce38`](https://github.com/colinhacks/zod/commit/7c9ce388ae39b2324c5ad05420ecf4732ebca6fe) Update docs for z.property check ([#&#8203;4863](https://github.com/colinhacks/zod/issues/4863)) - [`c432577`](https://github.com/colinhacks/zod/commit/c432577ad1a7201631ae0a4d80e945fc4937bcc9) docs: add jwt schema docs ([#&#8203;4867](https://github.com/colinhacks/zod/issues/4867)) - [`35e6a6f`](https://github.com/colinhacks/zod/commit/35e6a6f6d64d7d5ba58c4cb8c80105759b977c9b) Add llms.txt ([#&#8203;4915](https://github.com/colinhacks/zod/issues/4915)) - [`3ac7bf0`](https://github.com/colinhacks/zod/commit/3ac7bf00d0d924d1afa1031b798bdd72b59117db) Clean up Edit this Page - [`60a9372`](https://github.com/colinhacks/zod/commit/60a9372414955094b84aae2f30b491a039780b7c) Implement `llms-full.txt` ([#&#8203;5004](https://github.com/colinhacks/zod/issues/5004)) - [`73a1970`](https://github.com/colinhacks/zod/commit/73a1970e7fd0cdcb2ffac3f6f7db85da849ee3d8) 4.0.12 ### [`v4.0.11`](https://github.com/colinhacks/zod/releases/tag/v4.0.11) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.10...v4.0.11) #### Commits: - [`8e6a5f8`](https://github.com/colinhacks/zod/commit/8e6a5f8e48837fb403deb4025935e97a758ad6ca) Fix “Edit on Github” link ([#&#8203;4997](https://github.com/colinhacks/zod/issues/4997)) - [`930a2f6`](https://github.com/colinhacks/zod/commit/930a2f68d799889df4c1f662dfe61934db84fdd1) Fix number of errors in doc ([#&#8203;4993](https://github.com/colinhacks/zod/issues/4993)) - [`c762dbb`](https://github.com/colinhacks/zod/commit/c762dbb4fdb249cfddccdd69812da3f4b659df67) feat(locale): Add Yoruba (yo) locale ([#&#8203;4996](https://github.com/colinhacks/zod/issues/4996)) - [`9a34a3a`](https://github.com/colinhacks/zod/commit/9a34a3a60d92c44f695b08e4c665209aa7160e24) Zod 4.0.11 ([#&#8203;4981](https://github.com/colinhacks/zod/issues/4981)) ### [`v4.0.10`](https://github.com/colinhacks/zod/releases/tag/v4.0.10) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.9...v4.0.10) #### Commits: - [`291c1ca`](https://github.com/colinhacks/zod/commit/291c1ca9864570e68a6c104d869de467f665da86) Add should-build script - [`e32d99b`](https://github.com/colinhacks/zod/commit/e32d99b54fff920c4b0b451e9099b472d20a3c4b) Move should-build script - [`d4faf71`](https://github.com/colinhacks/zod/commit/d4faf71b8cc156a49bae23fc09c4d54b88f22bd5) Add v3 docs ([#&#8203;4972](https://github.com/colinhacks/zod/issues/4972)) - [`dfae371`](https://github.com/colinhacks/zod/commit/dfae37195bed15dce84af0b17ef04cdc3704ef5e) Update Jazz img on v3 docs - [`d6cd30d`](https://github.com/colinhacks/zod/commit/d6cd30d3898aaf592c6077464c1a45fd0f6f66d3) fix [#&#8203;4973](https://github.com/colinhacks/zod/issues/4973) ([#&#8203;4974](https://github.com/colinhacks/zod/issues/4974)) - [`1850496`](https://github.com/colinhacks/zod/commit/18504960cdce29529e37415b87fed1732facf1ef) Fix typo in `valype` ([#&#8203;4960](https://github.com/colinhacks/zod/issues/4960)) - [`4ec2f87`](https://github.com/colinhacks/zod/commit/4ec2f8776193642d91814521d8a4c22bbb766cb1) Add Zod Playground to zod 4 ecosystem ([#&#8203;4975](https://github.com/colinhacks/zod/issues/4975)) - [`2b571a2`](https://github.com/colinhacks/zod/commit/2b571a21875e9e3299de261e512dad300878c3a1) Update docs z.enum with object literal example ([#&#8203;4967](https://github.com/colinhacks/zod/issues/4967)) - [`813451d`](https://github.com/colinhacks/zod/commit/813451db7fcf64c5322835984eded9bfe95be1da) v4.0.10 ([#&#8203;4978](https://github.com/colinhacks/zod/issues/4978)) ### [`v4.0.9`](https://github.com/colinhacks/zod/releases/tag/v4.0.9) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.8...v4.0.9) #### Commits: - [`4e7a3ef`](https://github.com/colinhacks/zod/commit/4e7a3ef180f6a5525d9021638e9df20b3ca50456) v4.0.9 ([#&#8203;4970](https://github.com/colinhacks/zod/issues/4970)) ### [`v4.0.8`](https://github.com/colinhacks/zod/releases/tag/v4.0.8) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.7...v4.0.8) #### Commits: - [`3048d14`](https://github.com/colinhacks/zod/commit/3048d14bc7b803507302b8ee3cd1eeeffbd27396) Fix [#&#8203;4961](https://github.com/colinhacks/zod/issues/4961) ### [`v4.0.7`](https://github.com/colinhacks/zod/releases/tag/v4.0.7) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.6...v4.0.7) #### Commits: - [`7ab1b3c`](https://github.com/colinhacks/zod/commit/7ab1b3cd2e272a74c0f7c5cde70ee23c2ef288d6) Do not continue parsing in ZodPipe if issues exists. Closes [#&#8203;4926](https://github.com/colinhacks/zod/issues/4926). - [`34b400a`](https://github.com/colinhacks/zod/commit/34b400a5422bc30b48395cdd44007ff4e811fb71) 4.0.7 ### [`v4.0.6`](https://github.com/colinhacks/zod/releases/tag/v4.0.6) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.5...v4.0.6) #### Commits: - [`a3e4391`](https://github.com/colinhacks/zod/commit/a3e43911abb980f1830b68a440c231ae52eacec0) Unwiden catch input type ([#&#8203;4870](https://github.com/colinhacks/zod/issues/4870)) - [`499df78`](https://github.com/colinhacks/zod/commit/499df780b10dfcce29afba3e811757f7eade9570) Add RFC 9562 mentions. Closes [#&#8203;4872](https://github.com/colinhacks/zod/issues/4872) - [`d0493f3`](https://github.com/colinhacks/zod/commit/d0493f3dceb117972464f01cb0765262a5ffed70) Doc tweak - spread vs destructuring ([#&#8203;4919](https://github.com/colinhacks/zod/issues/4919)) - [`8dad394`](https://github.com/colinhacks/zod/commit/8dad394b805fd18cee8e44a37dab983916e0d92c) feat: Icelandic translation ([#&#8203;4920](https://github.com/colinhacks/zod/issues/4920)) - [`2ffdae1`](https://github.com/colinhacks/zod/commit/2ffdae1faafcc34639a7a846a55776c2a886a644) Bulgarian (bg) translation ([#&#8203;4928](https://github.com/colinhacks/zod/issues/4928)) - [`0973135`](https://github.com/colinhacks/zod/commit/09731358f69bb1238f6e00e0ca82e28c095b800f) docs: add valype to xToZodConverts ([#&#8203;4930](https://github.com/colinhacks/zod/issues/4930)) - [`d257340`](https://github.com/colinhacks/zod/commit/d2573409ab02e5d0c2a644315798999d619e4c89) Remove moduleResolution callout ([#&#8203;4932](https://github.com/colinhacks/zod/issues/4932)) - [`075970d`](https://github.com/colinhacks/zod/commit/075970d2aeb50c840840cc44559b31b16d7b6504) docs: add coercion note to fix compile errors ([#&#8203;4940](https://github.com/colinhacks/zod/issues/4940)) - [`b9e8a60`](https://github.com/colinhacks/zod/commit/b9e8a60ff44aa5fffc39617eec894117132fbbac) Add `@hey-api/openapi-ts` to Zod 3 ecosystem ([#&#8203;4949](https://github.com/colinhacks/zod/issues/4949)) - [`ad7b0ff`](https://github.com/colinhacks/zod/commit/ad7b0ffd91da4f0466c97b7b5e6b60f376ae4f33) Add `@hey-api/openapi-ts` to Zod 3 ecosystem ([#&#8203;4942](https://github.com/colinhacks/zod/issues/4942)) - [`4619109`](https://github.com/colinhacks/zod/commit/4619109e7927019837a3a13d4ab8bba5c72989de) feat(locales): add Danish translations ([#&#8203;4953](https://github.com/colinhacks/zod/issues/4953)) - [`cb84a57`](https://github.com/colinhacks/zod/commit/cb84a5711b83d25c7dcf218c4c01097cf036c1f5) Point to zod-v3-to-v4 codemod in Zod 4 migration guide ([#&#8203;4954](https://github.com/colinhacks/zod/issues/4954)) - [`28a5091`](https://github.com/colinhacks/zod/commit/28a5091092b22146a26f8a4e7c18e2943f53a86a) Update api.mdx ([#&#8203;4955](https://github.com/colinhacks/zod/issues/4955)) - [`7f3cf94`](https://github.com/colinhacks/zod/commit/7f3cf946ca9aa90031cb954d6f683cb09de4d894) Fix URL sup example ([#&#8203;4959](https://github.com/colinhacks/zod/issues/4959)) - [`17e7f3b`](https://github.com/colinhacks/zod/commit/17e7f3b4e1c2c97b3c9487c97ac6703a16ed1cfb) Add `@hey-api/openapi-ts` to Zod 4 ecosystem ([#&#8203;4950](https://github.com/colinhacks/zod/issues/4950)) - [`f75d852`](https://github.com/colinhacks/zod/commit/f75d85294df2ff4ccea056e8eeb7c14750fa929f) fix: escapes decimal place in `z.literal` ([#&#8203;4895](https://github.com/colinhacks/zod/issues/4895)) - [`7dd7484`](https://github.com/colinhacks/zod/commit/7dd7484802b1351c8b81d3d523aadd876fcdf73e) v4.0.6 ([#&#8203;4941](https://github.com/colinhacks/zod/issues/4941)) ### [`v4.0.5`](https://github.com/colinhacks/zod/releases/tag/v4.0.5) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.4...v4.0.5) #### Commits: - [`f91a73e`](https://github.com/colinhacks/zod/commit/f91a73ec23f9ec28d908af2caa643a54088516c5) Support pipes in discriminated unions. Closes [#&#8203;4856](https://github.com/colinhacks/zod/issues/4856) ([#&#8203;4861](https://github.com/colinhacks/zod/issues/4861)) - [`45afab0`](https://github.com/colinhacks/zod/commit/45afab0f846dffd591362b6f770017507eb185b5) 4.0.5 ### [`v4.0.4`](https://github.com/colinhacks/zod/releases/tag/v4.0.4) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.3...v4.0.4) #### Commits: - [`9335f05`](https://github.com/colinhacks/zod/commit/9335f0543d6359f9236e3e33b78cc5b2788dbe0f) Adds `ZodFirstPartyTypeKind` stub to fix module resolution failure inside `zod-to-json-schema` ### [`v4.0.3`](https://github.com/colinhacks/zod/releases/tag/v4.0.3) [Compare Source](https://github.com/colinhacks/zod/compare/44a936cb77961e57a0988d8a3c63d9c71fce69ac...v4.0.3) #### Commits: - [`5905a8d`](https://github.com/colinhacks/zod/commit/5905a8d810eff6f4677e6aa9e557f92a676805cf) Improve check-versions script - [`f3e749b`](https://github.com/colinhacks/zod/commit/f3e749b1b057a2cf0a0bce7e07abec4e0520e0f8) Remove global File interface - [`44a936c`](https://github.com/colinhacks/zod/commit/44a936cb77961e57a0988d8a3c63d9c71fce69ac) 4.0.2 - [`74006ed`](https://github.com/colinhacks/zod/commit/74006edd49e3fe8d74010090462859593c2bd1e2) Fix JSR provenance - [`ff4af5e`](https://github.com/colinhacks/zod/commit/ff4af5e889d4ad7136a9cde7202b16261db5c83c) 4.0.3 - [`ce573e8`](https://github.com/colinhacks/zod/commit/ce573e8799f86e2f68307eba95c2d40fc92617b7) Update test badge - [`9a7161a`](https://github.com/colinhacks/zod/commit/9a7161a976d6349f738c00cb6d6528c0407a65e8) Fix versions ### [`v4.0.2`](https://github.com/colinhacks/zod/compare/v4.0.1...44a936cb77961e57a0988d8a3c63d9c71fce69ac) [Compare Source](https://github.com/colinhacks/zod/compare/v4.0.1...44a936cb77961e57a0988d8a3c63d9c71fce69ac) ### [`v4.0.1`](https://github.com/colinhacks/zod/releases/tag/v4.0.1): v4.0.0 [Compare Source](https://github.com/colinhacks/zod/compare/79d4d80e3b47f04752c5c281077b53f889551441...v4.0.1) With this release, `zod@4.0.0` has been published to `npm`. There were no code changes between 3.25.76 and 4.0.0! Zod 4 has been stable for the past 6 weeks, but it was published inside <zod@3.25.x> on npm. this transitionary window gave the ecosystem time to incrementally support for Zod 4 (without dropping support for Zod 3). As there is now near-universal support for Zod 4 in the ecosystem, ths time feels right to finally put a bow on things 🎀 To upgrade to Zod 4: ``` npm upgrade zod@^4.0.0 ``` If you’ve already migrated to Zod 4 using the subpaths, there are no changes required. however you can optionally simplify your imports (recommended) ```ts // after upgrading to zod@4.0.0: import * as z from "zod"; // Zod 4 (regular) import * as z from "zod/mini" // Zod 4 Mini // these still work, but are no longer needed import * as z from "zod/v4"; import * as z from "zod/v4-mini": // if you still need Zod 3 import * as z from "zod/v3"; // Zod 3 ``` **Library authors** — if you've already implemented Zod 4 support according to the best practices outlined in the [Library authors](/library-authors) guide, bump your peer dependency to include `zod@^4.0.0`: ```json // package.json { "peerDependencies": { "zod": "^3.25.0 || ^4.0.0" } } ``` *There should be no other code changes necessary.* No code changes were made between the latest `3.25.x` release and `4.0.0`. This does not require a major version bump. ### [`v4.0.0`](https://github.com/colinhacks/zod/compare/v3.25.76...79d4d80e3b47f04752c5c281077b53f889551441) [Compare Source](https://github.com/colinhacks/zod/compare/v3.25.76...79d4d80e3b47f04752c5c281077b53f889551441) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNjguNSIsInVwZGF0ZWRJblZlciI6IjQzLjE2OC41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
renovate-bot added 1 commit 2026-05-22 10:02:23 +02:00
Owner

/oc check if the potentially breaking changes in this dependecy affect this app

/oc check if the potentially breaking changes in this dependecy affect this app
Owner

No breaking changes affect this app.

Zod v4 is declared as a dependency in mcp-wrapper/package.json but is not imported or used anywhere in the codebase. All 7 TypeScript source files and the test file were checked — none reference zod, zod/mini, or any Zod features.

Zod is an orphaned/leftover dependency. The upgrade has zero impact on this app.

opencode session  |  forgejo run

**No breaking changes affect this app.** Zod v4 is declared as a dependency in `mcp-wrapper/package.json` but is **not imported or used anywhere** in the codebase. All 7 TypeScript source files and the test file were checked — none reference `zod`, `zod/mini`, or any Zod features. Zod is an orphaned/leftover dependency. The upgrade has zero impact on this app. [opencode session](https://opencode.ai/s/sXTVPqfY)&nbsp;&nbsp;|&nbsp;&nbsp;[forgejo run](https://bitfreedom.net/code/apunkt/iai-mcp-opencode/actions/runs/1)
apunkt merged commit a5d9112b8a into main 2026-05-22 10:54:54 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: apunkt/iai-mcp-opencode#7
No description provided.