From dfdfaf465a8a8946e38d61c41a50ace9e92db45d Mon Sep 17 00:00:00 2001 From: Anna Bocharova Date: Tue, 15 Nov 2022 09:40:00 +0100 Subject: [PATCH] Take `path` parameter into account within `.parseAsync()` (#1513) 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. --- src/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.ts b/src/types.ts index d6165b658..2c42b1e36 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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));