From a693b9bbd1be87021b6d94579035785ad54d455c Mon Sep 17 00:00:00 2001 From: Kshitija Kadam <65657373+Xitija@users.noreply.github.com> Date: Thu, 26 Sep 2024 13:08:35 +0530 Subject: [PATCH] chore : code rabbit suggestions --- src/common/pipes/event-validation.pipe.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/common/pipes/event-validation.pipe.ts b/src/common/pipes/event-validation.pipe.ts index abad91f..bf6622c 100644 --- a/src/common/pipes/event-validation.pipe.ts +++ b/src/common/pipes/event-validation.pipe.ts @@ -101,13 +101,21 @@ export class RegistrationDateValidationPipe implements PipeTransform { currentDate: Date, isRestricted: boolean, ) { - if (registrationStartDate && registrationStartDate < currentDate && !isRestricted) { + if ( + registrationStartDate && + registrationStartDate < currentDate && + !isRestricted + ) { throw new BadRequestException( ERROR_MESSAGES.REGISTRATION_START_DATE_INVALID, ); } - if (registrationEndDate && registrationEndDate < currentDate && !isRestricted) { + if ( + registrationEndDate && + registrationEndDate < currentDate && + !isRestricted + ) { throw new BadRequestException( ERROR_MESSAGES.REGISTRATION_END_DATE_INVALID, ); @@ -119,7 +127,12 @@ export class RegistrationDateValidationPipe implements PipeTransform { registrationEndDate: Date | null, isRestricted: boolean, ) { - if (registrationStartDate > registrationEndDate && !isRestricted) { + if ( + registrationStartDate && + registrationEndDate && + registrationStartDate > registrationEndDate && + !isRestricted + ) { throw new BadRequestException( ERROR_MESSAGES.REGISTRATION_START_DATE_BEFORE_END_DATE, );