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", ".module.ts",
".request.ts", ".request.ts",
".presenter.ts", ".presenter.ts",
".exception.ts",
"main.ts" "main.ts"
], ],
"rootDir": "src", "rootDir": "src",

View File

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

View File

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