Skip to content

Fix/map z.int32() and z.uint32() to integer type - #399

Open
KasperiP wants to merge 1 commit into
asteasolutions:masterfrom
KasperiP:fix/int-formats-on-zod-v4
Open

KasperiP wants to merge 1 commit into
asteasolutions:masterfrom
KasperiP:fix/int-formats-on-zod-v4

Conversation

@KasperiP

Copy link
Copy Markdown

Fixes #398

Previously only Zod's safeint format (z.int(), z.number().int()) was mapped to integer. The other Zod v4 integer formats, int32 and uint32 were incorrectly mapped to number.

Change: NumberTransformer now checks the format against a set typed with Zod's $ZodNumberFormats, including safeint, int32, and uint32.

Schema Before After
z.int32() number integer
z.uint32() number integer
z.float32() / z.float64() number number (unchanged)

Only the safeint format (z.int(), z.number().int()) was mapped to
integer, so the other Zod v4 integer formats int32 and uint32 were
generated as number.

Fixes asteasolutions#398
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 int32() outputs type number instead of integer

1 participant