Skip to content

[TypeGen]: emit Zod 4 top-level format factories (fix #13)#14

Merged
MistyKuu merged 1 commit into
masterfrom
fix/zod-v4-uuid-format
Jun 10, 2026
Merged

[TypeGen]: emit Zod 4 top-level format factories (fix #13)#14
MistyKuu merged 1 commit into
masterfrom
fix/zod-v4-uuid-format

Conversation

@MistyKuu

Copy link
Copy Markdown
Owner

Closes #13.

Problem

The Zod emitter generated z.string().uuid(), which Zod 4 deprecated. Reported by @RejectKid in #13 — it should be z.uuid().

Change

The emitter now always targets Zod 4 and emits the top-level format factories. Zod 3's deprecated chained forms are no longer supported.

C# / attribute before after
System.Guid z.string().uuid() z.uuid()
System.DateTime z.string().datetime() z.iso.datetime()
System.DateOnly z.string().date() z.iso.date()
[ZEmail] z.string().email() z.email()
[ZUrl] z.string().url() z.url()

For attribute-driven formats, ApplyStringFormat swaps the z.string() base for the factory so trailing .min()/.max()/.regex() still chain.

Tests

  • Unit assertions updated to the Zod 4 output.
  • Compilation tests pinned to zod@4.4.3 (added --skipLibCheck/--esModuleInterop for zod 4's .d.cts declarations).
  • New compilation test type-checks the format factories against a real Zod 4 install.
  • Full TypeGen suite: 241/241 passing.

Docs (emitters/zod.md) updated; consumers should npm install zod@^4.

🤖 Generated with Claude Code

Closes #13. The Zod emitter produced z.string().uuid(), which Zod 4
deprecated. Switch to the top-level factories — z.uuid(), z.email(),
z.url(), z.iso.datetime(), z.iso.date() — for both type mapping
(Guid/DateTime/DateOnly) and attribute-driven formats ([ZEmail]/[ZUrl]).
Drops support for the deprecated Zod 3 chained forms.

Compilation tests now pin zod@4.4.3 (with --skipLibCheck/--esModuleInterop
for zod 4's .d.cts files) and a new test type-checks the format factories
against a real Zod 4 install.
@MistyKuu MistyKuu merged commit 88125d0 into master Jun 10, 2026
1 check passed
@MistyKuu MistyKuu deleted the fix/zod-v4-uuid-format branch June 10, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zod schema uuid

1 participant