• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wger-project / react / 18075690066

28 Sep 2025 02:32PM UTC coverage: 75.232% (-0.4%) from 75.672%
18075690066

push

github

web-flow
Merge pull request #1126 from wger-project/feature/exercise-submission

Use new endpoint for exercise submission

1723 of 2590 branches covered (66.53%)

Branch coverage included in aggregate %.

64 of 120 new or added lines in 14 files covered. (53.33%)

6 existing lines in 1 file now uncovered.

5500 of 7011 relevant lines covered (78.45%)

28.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.1
/src/utils/forms.ts
1
interface ValidationErrorResponseSubList {
2
    [key: string]: ValidationErrorResponseList[];
3
}
4

5
interface ValidationErrorResponseList {
6
    [key: string]: string[];
7
}
8

9
interface ValidationErrorResponse {
10
    [key: string]: string;
11
}
12

13
export function collectValidationErrors(
16✔
14
    errors: ValidationErrorResponseList | ValidationErrorResponseSubList | ValidationErrorResponse | undefined | null,
15
    parentKey?: string
16
): string[] {
17
    const allErrors: string[] = [];
310✔
18
    if (!errors) {
310✔
19
        return allErrors;
305✔
20
    }
21

22
    for (const field in errors) {
5✔
23
        if (Object.hasOwn(errors, field)) {
5!
24
            const value = errors[field];
5✔
25
            const key = parentKey ? `${parentKey}.${field}` : field;
5✔
26

27
            if (Array.isArray(value)) {
5✔
28
                if (value.length > 0 && typeof value[0] === "object" && value[0] !== null) {
4✔
29
                    // If value is an array of objects, treat as sublist and recurse
30
                    for (const sub of value) {
1✔
31
                        if (typeof sub === "object" && sub !== null) {
1!
32
                            allErrors.push(...collectValidationErrors(sub, key));
1✔
33
                        } else {
NEW
34
                            allErrors.push(`${key}: ${sub}`);
×
35
                        }
36
                    }
37
                } else {
38
                    // If value is an array of strings, treat as error messages
39
                    allErrors.push(...value.map(error => `${key}: ${error}`));
4✔
40
                }
41
            } else if (typeof value === "string") {
1!
42
                // If value is a string, treat as a single error message
43
                allErrors.push(`${key}: ${value}`);
1✔
44
            }
45
        }
46
    }
47

48
    return allErrors;
5✔
49
}
50

51
export function errorsToString(errors: ValidationErrorResponse): string {
16✔
52
    const allErrors = collectValidationErrors(errors);
303✔
53
    return allErrors.length > 0 ? allErrors.join(" | ") : "";
303!
54
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc