add extra check to prevent vanilla 'validate' request to fail on ApiErrors

This commit is contained in:
Jacob Overgaard
2024-05-02 11:19:08 +02:00
parent ddaebc8c8a
commit b23e63094f

View File

@@ -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?.();