Skip to content

Conversation

@Abdalrhman-Almarakeby
Copy link
Contributor

Fixes the error messages for Zod numeric formats so that they correctly show that values are allowed to equal the minimum and maximum bounds.

This issue affected: z.int(), z.float32(), z.float64(), z.int32(), z.uint32(), z.int64(), and z.uint64() (all of the numeric formats). This PR updates their error messages.

Previously:

z.int32().safeParse(2147483648)
// Error message: "Too big: expected number to be <2147483647"

Now:

z.int32().safeParse(2147483648)
// Error message: "Too big: expected number to be <=2147483647"

Which is correct because 2147483647 parses successfully.

Same for "Too small" errors and all other numeric formats.

Also updates the docs to clarify that minimum and maximum bounds are inclusive.

Fixes #5436.

@Abdalrhman-Almarakeby Abdalrhman-Almarakeby changed the title Fix numeric format error messages to be inclusive Fix numeric formats error messages to be inclusive Nov 27, 2025
@Abdalrhman-Almarakeby Abdalrhman-Almarakeby force-pushed the fix/make-numeric-formats-error-messages-inclusive branch from 54d42ed to 398751c Compare November 27, 2025 11:43
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.

int.32() throws wrong message on value too big

1 participant