Skip to content

Commit

Permalink
fixed safeCoerceObject for extra feilds
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-oloughlin committed Nov 15, 2023
1 parent 7951b33 commit 825bdd6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function safeCoerceObject<T extends z.ZodObject<z.ZodRawShape>>(
.map(([key, value]) => {
const valueSchema = schema.shape[key]

let parsed = valueSchema.safeParse(value)
let parsed = valueSchema?.safeParse(value) ?? z.any().safeParse(value)

if (!parsed.success) {
parsed = typeof value === "object" && !(value instanceof Date)
Expand Down

0 comments on commit 825bdd6

Please sign in to comment.