MCPcopy Index your code
hub / github.com/webiny/webiny-js / createValidationErrorData

Function createValidationErrorData

packages/utils/src/createZodError.ts:21–46  ·  view source on GitHub ↗
(error: ZodError)

Source from the content-addressed store, hash-verified

19}
20
21const createValidationErrorData = (error: ZodError) => {
22 return {
23 invalidFields: error.issues.reduce<OutputErrors>((collection, issue) => {
24 const name = issue.path.join(".");
25 if (!name && !issue.code) {
26 return collection;
27 }
28
29 const key =
30 name ||
31 issue.path.join(".") ||
32 issue.message ||
33 issue.code ||
34 generateAlphaNumericId();
35 collection[key] = {
36 code: issue.code,
37 message: issue.message,
38 data: {
39 path: issue.path
40 }
41 };
42
43 return collection;
44 }, {})
45 };
46};
47
48export const createZodError = (error: ZodError) => {
49 return new WebinyError({

Callers 1

createZodErrorFunction · 0.85

Calls 2

reduceMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected