diff --git a/deno/lib/types.ts b/deno/lib/types.ts index 46539e1bb..3d8026c68 100644 --- a/deno/lib/types.ts +++ b/deno/lib/types.ts @@ -1556,8 +1556,12 @@ export class ZodObject< const { status, ctx } = this._processInputParams(input); const { shape, keys: shapeKeys } = this._getCached(); - const dataKeys = util.objectKeys(ctx.data); - const extraKeys = dataKeys.filter((k) => !shapeKeys.includes(k)); + const extraKeys: string[] = []; + for (const key in ctx.data) { + if (!shapeKeys.includes(key)) { + extraKeys.push(key); + } + } const pairs: { key: ParseReturnType; diff --git a/src/types.ts b/src/types.ts index 9a76b805e..358b744c3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1556,8 +1556,12 @@ export class ZodObject< const { status, ctx } = this._processInputParams(input); const { shape, keys: shapeKeys } = this._getCached(); - const dataKeys = util.objectKeys(ctx.data); - const extraKeys = dataKeys.filter((k) => !shapeKeys.includes(k)); + const extraKeys: string[] = []; + for (const key in ctx.data) { + if (!shapeKeys.includes(key)) { + extraKeys.push(key); + } + } const pairs: { key: ParseReturnType;