feat: add validation to prevent class creation for past dates

This commit is contained in:
Rémi 2025-01-04 19:04:48 +01:00
parent 341faa3bb0
commit 95ccfc884c

View File

@ -110,6 +110,10 @@ export class ClassService {
const date = moment(createRoomClassDto.date);
// Check if the date is before the current date
if (date.isBefore(moment().startOf("day")))
throw new HttpException("Can't create a room for a class that has passed", 400);
const firstTimeStart = createRoomClassDto.times.reduce((prev, current) =>
moment(current.start, "HH:mm").isBefore(moment(prev.start, "HH:mm"))
? current