Skip to content

[V4] Confusing error message with zod.number and Infinity #5186

@lowlighter

Description

@lowlighter

Hi !

So I know that Infinity is not a valid value anymore for zod.number(), but the default Zod error message that gets thrown is quite confusing:

Invalid input: expected number, received number

I assume it's because it uses typeof to generate this message

> zod.number().parse(Infinity)
Uncaught ZodError: [
  {
    "expected": "number",
    "code": "invalid_type",
    "received": "Infinity",
    "path": [],
    "message": "Invalid input: expected number, received number"
  }
]
    at <anonymous>:1:35

> zod.prettifyError(zod.number().safeParse(Infinity).error)
"✖ Invalid input: expected number, received number"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions