diff --git a/client/src/components/manageProjects/createNewEvent.jsx b/client/src/components/manageProjects/createNewEvent.jsx index a74c8526..f320b129 100644 --- a/client/src/components/manageProjects/createNewEvent.jsx +++ b/client/src/components/manageProjects/createNewEvent.jsx @@ -99,6 +99,7 @@ const CreateNewEvent = ({ handleInputChange={handleInputChange} formValues={formValues} formErrors={formErrors} + setFormErrors={setFormErrors} title="Create New Recurring Event" >
diff --git a/client/src/components/manageProjects/eventForm.jsx b/client/src/components/manageProjects/eventForm.jsx index 7666fc66..ecc1375a 100644 --- a/client/src/components/manageProjects/eventForm.jsx +++ b/client/src/components/manageProjects/eventForm.jsx @@ -1,5 +1,6 @@ import React from 'react'; import { createClockHours } from '../../utils/createClockHours'; +import validateEventForm from './utilities/validateEventForm'; import { Box, TextField, @@ -14,12 +15,18 @@ const EventForm = ({ title, formValues, formErrors, + setFormErrors, handleInputChange, children, }) => { // This creates the clock hours for the form const clockHours = createClockHours(); - + const handleInputChangeWithValidation = (e) => { + const { name, value } = e.target; + handleInputChange(e); + const errors = validateEventForm({ ...formValues, [name]: value }); + setFormErrors(errors || {}); + }; return ( {title &&

{title}

} diff --git a/client/src/components/manageProjects/utilities/validateEventForm.js b/client/src/components/manageProjects/utilities/validateEventForm.js index 1976e124..54b883db 100644 --- a/client/src/components/manageProjects/utilities/validateEventForm.js +++ b/client/src/components/manageProjects/utilities/validateEventForm.js @@ -1,11 +1,13 @@ -import validator from 'validator'; import { isWordInArrayInString } from './../../../utils/stringUtils.js'; import { eventNameBlacklistArr } from '../../../utils/blacklist.js'; const validateEventForm = (vals, projectToEdit) => { let newErrors = {}; Object.keys(vals).forEach((key) => { - let blacklistedStrings = isWordInArrayInString( eventNameBlacklistArr, vals[key].toLowerCase() ); + let blacklistedStrings = isWordInArrayInString( + eventNameBlacklistArr, + vals[key].toLowerCase() + ); switch (key) { case 'name': // Required @@ -58,6 +60,10 @@ const validateEventForm = (vals, projectToEdit) => { export default validateEventForm; -function validateLink(str) { - return validator.isURL(str); +function validateLink(url) { + const ZoomMeetRegex = + /^(?:https:\/\/)?(?:www\.)?(?:[a-z0-9-]+\.)?zoom\.us\/j\/[0-9]+(\?pwd=[a-zA-Z0-9]+)?$/; + const GoogleMeetRegex = + /^(?:https:\/\/)?(?:[a-z0-9-]+\.)?meet\.google\.com\/[a-zA-Z0-9-]+$/; + return ZoomMeetRegex.test(url) || GoogleMeetRegex.test(url); }