Skip to content

Commit

Permalink
Add documentation to checkInputs function
Browse files Browse the repository at this point in the history
  • Loading branch information
Sydney-tran committed Nov 2, 2023
1 parent 037582e commit d2e05ad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/includes/CourseCreatePopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ const CourseCreatePopup = ({ setCourseCreatePopup, userId }: Props) => {
setStateFunction(target.value);
};

/**
* This function checks if the course code and name are valid. Valid course codes are in the form:
* group of chars, space, and then a group of numbers. Valid course names are not empty strings.
* If either the course code or name are invalid, a corresponding error message is shown.
* @returns true if both the course code and name are valid, false otherwise.
*/
const checkInputs = () => {
const codeArray = code.split(" ");
const codeError = codeArray.length !== 2 || !/^[a-zA-Z]+$/.test(codeArray[0]) || !/^\d+$/.test(codeArray[1]);
Expand Down

0 comments on commit d2e05ad

Please sign in to comment.