colinhacks / zod

TypeScript-first schema validation with static type inference

Home Page:https://zod.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

We should not allow `optional`, `nullish`, or `nullable` on `z.coerce` schemas

scotttrinh opened this issue · comments

Since z.coerce.* schemas will always return the primitive, even if you pass undefined or null, we should disallow this. Also, things like z.union([z.coerce.string(), z.coerce.number()]) will always return a string since the first schema will just always succeed.