From 7447e5f114f64d8f9fecd51b995f5a7b4a2d0c8f Mon Sep 17 00:00:00 2001 From: Trillium Smith Date: Tue, 5 Sep 2023 14:17:24 -0700 Subject: [PATCH] feat: Update 'name' error message to be more clear --- .../manageProjects/utilities/validateEventForm.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/client/src/components/manageProjects/utilities/validateEventForm.js b/client/src/components/manageProjects/utilities/validateEventForm.js index e0d27fca..90b1febc 100644 --- a/client/src/components/manageProjects/utilities/validateEventForm.js +++ b/client/src/components/manageProjects/utilities/validateEventForm.js @@ -11,13 +11,23 @@ const validateEventForm = (vals, projectToEdit) => { newErrors = { ...newErrors, name: 'Event name is required' }; } else if ( isWordInArrayInString( - ['meeting', 'mtg', projectToEdit.name.toLowerCase()], + ['meeting', 'mtg'], vals[key].toLowerCase() ) ) { newErrors = { ...newErrors, - name: "Event name cannot contain 'meeting' or 'mtg' or the project name", + name: "Event name cannot contain 'meeting' or 'mtg'", + }; + } else if ( + isWordInArrayInString( + [projectToEdit.name.toLowerCase()], + vals[key].toLowerCase() + ) + ) { + newErrors = { + ...newErrors, + name: `Event name cannot contain the Project Name: '${projectToEdit.name}'`, }; } break;