Skip to content

Commit f3ef251

Browse files
committed
add extra check to prevent vanilla 'validate' request to fail on ApiErrors
1 parent b96ded3 commit f3ef251

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/packages/core/validation/context/server-model-validation.context.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ export class UmbServerModelValidationContext
6060
if (!this.#isValid) {
6161
// We are missing some typing here, but we will just go wild with 'as any': [NL]
6262
const readErrorBody = (error as any).body;
63-
Object.keys(readErrorBody.errors).forEach((path) => {
64-
this.#serverFeedback.push({ path, messages: readErrorBody.errors[path] });
65-
});
63+
// Check if there are validation errors, since the error might be a generic ApiError
64+
if (readErrorBody?.errors) {
65+
Object.keys(readErrorBody.errors).forEach((path) => {
66+
this.#serverFeedback.push({ path, messages: readErrorBody.errors[path] });
67+
});
68+
}
6669
}
6770

6871
this.#validatePromiseResolve?.();

0 commit comments

Comments
 (0)