Skip to content

Commit

Permalink
Take path parameter into account within .parseAsync() (#1513)
Browse files Browse the repository at this point in the history
Line 258 is inconsistent with the similar line 227.

```
// .parse():
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
// .parseAsync():
const maybeAsyncResult = this._parse({ data, path: [], parent: ctx });
```

`path` parameter is not taken into account when using `.parseAync()` method.
  • Loading branch information
RobinTail committed Nov 15, 2022
1 parent 2147e29 commit dfdfaf4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/types.ts
Expand Up @@ -255,7 +255,7 @@ export abstract class ZodType<
parsedType: getParsedType(data),
};

const maybeAsyncResult = this._parse({ data, path: [], parent: ctx });
const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
const result = await (isAsync(maybeAsyncResult)
? maybeAsyncResult
: Promise.resolve(maybeAsyncResult));
Expand Down

0 comments on commit dfdfaf4

Please sign in to comment.