(
data: unknown,
params?: util.InexactPartial<ParseParams>
)
| 296 | } |
| 297 | |
| 298 | async safeParseAsync( |
| 299 | data: unknown, |
| 300 | params?: util.InexactPartial<ParseParams> |
| 301 | ): Promise<SafeParseReturnType<Input, Output>> { |
| 302 | const ctx: ParseContext = { |
| 303 | common: { |
| 304 | issues: [], |
| 305 | contextualErrorMap: params?.errorMap, |
| 306 | async: true, |
| 307 | }, |
| 308 | path: params?.path || [], |
| 309 | schemaErrorMap: this._def.errorMap, |
| 310 | parent: null, |
| 311 | data, |
| 312 | parsedType: getParsedType(data), |
| 313 | }; |
| 314 | |
| 315 | const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx }); |
| 316 | const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult)); |
| 317 | return handleResult(ctx, result); |
| 318 | } |
| 319 | |
| 320 | /** Alias of safeParseAsync */ |
| 321 | spa = this.safeParseAsync; |
no test coverage detected