MCPcopy
hub / github.com/colinhacks/zod / safeParse

Function safeParse

packages/zod/src/v3/types.ts:229–245  ·  packages/zod/src/v3/types.ts::safeParse
(data: unknown, params?: util.InexactPartial<ParseParams>)

Source from the content-addressed store, hash-verified

227 }
228
229 safeParse(data: unknown, params?: util.InexactPartial<ParseParams>): SafeParseReturnType<Input, Output> {
230 const ctx: ParseContext = {
231 common: {
232 issues: [],
233 async: params?.async ?? false,
234 contextualErrorMap: params?.errorMap,
235 },
236 path: params?.path || [],
237 schemaErrorMap: this._def.errorMap,
238 parent: null,
239 data,
240 parsedType: getParsedType(data),
241 };
242 const result = this._parseSync({ data, path: ctx.path, parent: ctx });
243
244 return handleResult(ctx, result);
245 }
246
247 class="st">"~validate"(data: unknown): StandardSchemaV1.Result<Output> | Promise<StandardSchemaV1.Result<Output>> {
248 const ctx: ParseContext = {

Callers 2

schemas.tsFile · 0.85

Calls 2

handleResultFunction · 0.85
getParsedTypeFunction · 0.50

Tested by

no test coverage detected