feat: menambahkan validasi end time untuk create dan update time group

pull/143/head
Firman Ramdhani 2025-05-28 15:48:36 +07:00
parent a80e2e3419
commit 339b2bdab6
2 changed files with 20 additions and 0 deletions

View File

@ -40,6 +40,16 @@ export class CreateTimeGroupManager extends BaseCreateManager<TimeGroupEntity> {
'Waktu maksimum penggunaan harus lebih kecil dari waktu selesai.', 'Waktu maksimum penggunaan harus lebih kecil dari waktu selesai.',
); );
} }
return;
} else if (this.data.start_time && this.data.end_time) {
const format = 'HH:mm';
const start_time = moment(this.data.start_time, format);
const end_time = moment(this.data.end_time, format);
if (end_time.isBefore(start_time)) {
throw new Error('Waktu akhir harus lebih besar dari waktu mulai.');
}
return;
} }
return; return;
} }

View File

@ -41,6 +41,16 @@ export class UpdateTimeGroupManager extends BaseUpdateManager<TimeGroupEntity> {
'Waktu maksimum penggunaan harus lebih kecil dari waktu selesai.', 'Waktu maksimum penggunaan harus lebih kecil dari waktu selesai.',
); );
} }
return;
} else if (this.data.start_time && this.data.end_time) {
const format = 'HH:mm';
const start_time = moment(this.data.start_time, format);
const end_time = moment(this.data.end_time, format);
if (end_time.isBefore(start_time)) {
throw new Error('Waktu akhir harus lebih besar dari waktu mulai.');
}
return;
} }
return; return;
} }