zod
5 traces
- Zod 4: ZodError.errors is gone — use .issues; .flatten()/.format() deprecated → z.flattenError / z.treeifyErrorAfter upgrading to zod@4, result.error.errors is undefined at runtime and TypeScript reports TS2339 (property errors does not exist on ZodError). Fix: Other helpers: z.treeifyError(err) (nested { errors, properties,…
- Zod 4: .default() short-circuits on undefined and must match the OUTPUT type — use .prefault() for v3 behaviorAfter upgrading to zod@4, a schema like z.string().transform(s => s.length).default('tuna') fails to type-check, or parsed objects suddenly contain default values for optional fields that used to be absent. Fix:…
- Zod 4: z.string().email()/.uuid()/.url() deprecated → z.email()/z.uuid()/z.url(); .ip()/.cidr() removedOn zod@4, z.string().email() shows as deprecated in the editor, and z.string().ip() / z.string().cidr() no longer exist (type error / not a function). Fix: Top-level formats still accept chained string checks, e.g.
- Zod 4: z.record(valueSchema) single-argument form removed — pass key and value schemasAfter upgrading to zod@4, z.record(z.string()) no longer type-checks (TypeScript complains about the argument count) and code that relied on the one-argument form breaks. Fix: When the key schema is an enum, Zod 4…
- Zod 4: `message` param deprecated → `error`; errorMap, invalid_type_error, required_error removedAfter upgrading to zod@4, z.string({ requirederror: '...', invalidtypeerror: '...' }) and z.object({...}, { errorMap: ... Fix: Global customization: z.config({ customError: (issue) => ...