From 05779a56c135f35ceab44e211fd6ec1b3314bbdf Mon Sep 17 00:00:00 2001 From: Mawoka Date: Wed, 28 Dec 2022 11:58:57 +0100 Subject: [PATCH] :bug: Fixed incorrect errors with Slides --- frontend/src/lib/yupSchemas.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/frontend/src/lib/yupSchemas.ts b/frontend/src/lib/yupSchemas.ts index 664daea..3c0eddf 100644 --- a/frontend/src/lib/yupSchemas.ts +++ b/frontend/src/lib/yupSchemas.ts @@ -77,21 +77,23 @@ export const dataSchema = yup.object({ if (Array.isArray(v)) { try { if (typeof v[0].right === 'boolean') { - // console.log('ABCDQuestionSchema'); + console.log('ABCDQuestionSchema'); return ABCDQuestionSchema; } else if (v[0].answer !== undefined) { - // console.log('VotingQuestionSchema'); + console.log('VotingQuestionSchema'); return VotingQuestionSchema; } else { - // console.log('SlideQuestionSchema'); - return yup.string().required(); + console.log('SlideQuestionSchema'); + return yup.string().required().nullable(); } } catch { - // console.log('SlideQuestionSchema'); - return yup.string().required(); + console.log('SlideQuestionSchema'); + return yup.string().required("The slide mustn't be empty").nullable(); } + } else if (typeof v === 'string' || v instanceof String) { + return yup.string().required("The slide mustn't be empty").nullable(); } else { - // console.log('RangeQuestionSchema'); + console.log('RangeQuestionSchema'); return RangeQuestionSchema; } })