From 9aa5cc97cf7d62a24482634be659aace5b050e6d Mon Sep 17 00:00:00 2001 From: corpulent Date: Tue, 2 Aug 2022 23:15:22 +0300 Subject: [PATCH] fix: yup error a list of objects --- services/frontend/src/utils/forms.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/services/frontend/src/utils/forms.ts b/services/frontend/src/utils/forms.ts index af22bf6..5810897 100644 --- a/services/frontend/src/utils/forms.ts +++ b/services/frontend/src/utils/forms.ts @@ -208,7 +208,16 @@ export const reportErrorsAndSubmit = (formik: any) => () => { if (errors.length > 0) { // eslint-disable-next-line @typescript-eslint/no-unused-vars for (const [_field, message] of errors) { - toaster(message as string, "error"); + if (Array.isArray(message)) { + message.forEach((m: object) => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + for (const [_, value] of Object.entries(m)) { + toaster(value as string, "error"); + } + }); + } else { + toaster(message as string, "error"); + } } } else { formik.submitForm();