time request

This commit is contained in:
sbriat 2023-04-11 15:17:40 +02:00
parent 56bdd11970
commit 1e4aa0eadc
3 changed files with 6 additions and 5 deletions

View File

@ -90,6 +90,7 @@
".module.ts",
".request.ts",
".presenter.ts",
".exception.ts",
"main.ts"
],
"rootDir": "src",

View File

@ -1,11 +1,9 @@
import { MatcherException } from '../../exceptions/matcher.exception';
import { MarginDurations } from './margin-durations.type';
import { IRequestTime } from '../interfaces/time-request.interface';
import { TimingDays, TimingFrequency } from './timing';
import { TimingDays, TimingFrequency, Days } from './timing';
import { Schedule } from './schedule.type';
const days = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
export class Time {
_timeRequest: IRequestTime;
_defaultMarginDuration: number;
@ -84,7 +82,7 @@ export class Time {
}
if (
!Object.keys(this._timeRequest.schedule).some((elem) =>
days.includes(elem),
Days.includes(elem),
)
) {
throw new MatcherException(3, 'No valid day in the given schedule');
@ -140,7 +138,7 @@ export class Time {
if (this._timeRequest.marginDurations) {
if (
!Object.keys(this._timeRequest.marginDurations).some((elem) =>
days.includes(elem),
Days.includes(elem),
)
) {
throw new MatcherException(

View File

@ -12,3 +12,5 @@ export enum TimingDays {
'fri',
'sat',
}
export const Days = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];