Skip to content

Commit

Permalink
Merge pull request #1057 from tmcw/faster-extra-keys
Browse files Browse the repository at this point in the history
Faster extra keys detection
  • Loading branch information
colinhacks authored Apr 4, 2022
2 parents 0acd6f6 + 024257c commit 157f8c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions deno/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>;
Expand Down
8 changes: 6 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>;
Expand Down

0 comments on commit 157f8c5

Please sign in to comment.