From b23e63094f7e226821167658e7af662dd4dd7525 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 2 May 2024 11:19:08 +0200 Subject: [PATCH] add extra check to prevent vanilla 'validate' request to fail on ApiErrors --- .../context/server-model-validation.context.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts index 21f0d827fc..6feba69aa1 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/validation/context/server-model-validation.context.ts @@ -60,9 +60,12 @@ export class UmbServerModelValidationContext if (!this.#isValid) { // We are missing some typing here, but we will just go wild with 'as any': [NL] const readErrorBody = (error as any).body; - Object.keys(readErrorBody.errors).forEach((path) => { - this.#serverFeedback.push({ path, messages: readErrorBody.errors[path] }); - }); + // Check if there are validation errors, since the error might be a generic ApiError + if (readErrorBody?.errors) { + Object.keys(readErrorBody.errors).forEach((path) => { + this.#serverFeedback.push({ path, messages: readErrorBody.errors[path] }); + }); + } } this.#validatePromiseResolve?.();