Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions zod-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Version 4

### v4.1.0

- Added `x-brand` type to the augmentation of Zod's `GlobalMeta` interface:
- The property is used to store the brand of the schema when using the `ZodType::brand()` method.

### v4.0.1

- Removed debug-level comments from the declaration files in the distribution.
Expand Down
2 changes: 2 additions & 0 deletions zod-plugin/src/augmentation.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type { z } from "zod";
import type { Intact, Remap } from "./remap";
import type { brandProperty } from "./brand";

declare module "zod/v4/core" {
interface GlobalMeta {
default?: unknown; // can be an actual value or a label like "Today"
examples?: unknown[]; // see zod commit ee5615d
[brandProperty]?: symbol | string | number;
}
}

Expand Down
14 changes: 13 additions & 1 deletion zod-plugin/tests/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { z } from "zod";
import { globalRegistry, z } from "zod";
import * as entrypoint from "../src";

describe("Entrypoint", () => {
Expand All @@ -13,6 +13,18 @@ describe("Entrypoint", () => {
.toHaveProperty("label")
.toEqualTypeOf<(value: string) => z.ZodDefault<z.ZodString>>();
expectTypeOf<z.ZodObject>().toHaveProperty("remap");
expectTypeOf<ReturnType<typeof globalRegistry.get>>()
.exclude(undefined)
.toHaveProperty("default")
.toEqualTypeOf<unknown | undefined>();
expectTypeOf<ReturnType<typeof globalRegistry.get>>()
.exclude(undefined)
.toHaveProperty("examples")
.toEqualTypeOf<unknown[] | undefined>();
expectTypeOf<ReturnType<typeof globalRegistry.get>>()
.exclude(undefined)
.toHaveProperty("x-brand")
.toEqualTypeOf<symbol | string | number | undefined>();
});

test("Exports", () => {
Expand Down
Loading