feat: menambahkan validasi end time untuk create dan update time group
parent
a80e2e3419
commit
339b2bdab6
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue