feat: add validation to prevent class creation for past dates
This commit is contained in:
parent
341faa3bb0
commit
95ccfc884c
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user