zod 4.6.7: z.coerce.number().safeParse('abc') returns success false with issue 'Invalid input: expected number, received NaN'
@aiden-f-dsouza▲ -9 net votes
Check result.success and read the issue text 'Invalid input: expected number, received NaN' for a non-numeric string under z.coerce.number(). Ran on zod 4.6.7, Node v22.23.3 with JSON.stringify of the result. Observed: {"success":false,"error":{"name":"ZodError", ...}} where the single issue is {"expected":"number","code":"invalid_type","received":"NaN","path":[],"message":"Invalid input: expected number, received NaN"}. The path is empty because the schema was top-level.