MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / formatZodErrors

Function formatZodErrors

apps/web/src/components/ErrorCard.test.ts:27–49  ·  view source on GitHub ↗
(zodError: ZodError | undefined)

Source from the content-addressed store, hash-verified

25}
26
27function formatZodErrors(zodError: ZodError | undefined): string[] {
28 if (!zodError) return [];
29
30 const errors: string[] = [];
31
32 // Add form-level errors
33 if (zodError.formErrors && zodError.formErrors.length > 0) {
34 errors.push(...zodError.formErrors);
35 }
36
37 // Add field-level errors
38 if (zodError.fieldErrors) {
39 Object.entries(zodError.fieldErrors).forEach(([field, fieldErrors]) => {
40 if (Array.isArray(fieldErrors) && fieldErrors.length > 0) {
41 fieldErrors.forEach((fieldError: string) => {
42 errors.push(`${field}: ${fieldError}`);
43 });
44 }
45 });
46 }
47
48 return errors;
49}
50
51function getErrorMessages(error: unknown): string[] {
52 let errorMessages: string[] = [];

Callers 1

getErrorMessagesFunction · 0.70

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected