Ensure 'validationErrors' is checked for details field errors when parsing an error response on update

This commit is contained in:
Dean 2022-10-28 15:46:03 +01:00
parent 074008b499
commit 8018365010
1 changed files with 5 additions and 1 deletions

View File

@ -70,7 +70,11 @@
.map(([key, error]) => ({ dataPath: key, message: error })) .map(([key, error]) => ({ dataPath: key, message: error }))
.flat() .flat()
} }
} else if (error.status === 400) { } else if (error.status === 400 && response?.validationErrors) {
errors = Object.keys(response.validationErrors).map(field => ({
message: `${field} ${response.validationErrors[field][0]}`,
}))
} else {
errors = [{ message: response?.message || "Unknown error" }] errors = [{ message: response?.message || "Unknown error" }]
} }
} else { } else {