Skip to content
Closed
6 changes: 6 additions & 0 deletions course-matrix/backend/src/constants/availableFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ export const availableFunctions: AvailableFunctions = {
try {
// Extract event details and course information from the request
const { name, semester, courses, restrictions } = args;
if (name.length >= 50) {
return {
status: 400,
error: "timetable title is over 50 characters long",
};
}

const courseOfferingsList: OfferingList[] = [];
const validCourseOfferingsList: GroupedOfferingList[] = [];
Expand Down
13 changes: 13 additions & 0 deletions course-matrix/backend/src/controllers/timetablesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export default {
.status(400)
.json({ error: "timetable title and semester are required" });
}
// Timetables cannot be longer than 50 characters.
if (timetable_title.length > 50) {
return res
.status(400)
.json({ error: "Timetable Title cannot be over 50 characters long" });
}

// Check if a timetable with the same title already exist for this user
const { data: existingTimetable, error: existingTimetableError } =
Expand Down Expand Up @@ -169,6 +175,13 @@ export default {
});
}

// Timetables cannot be longer than 50 characters.
if (timetable_title.length > 50) {
return res
.status(400)
.json({ error: "Timetable Title cannot be over 50 characters long" });
}

//Retrieve the authenticated user
const user_id = (req as any).user.id;

Expand Down