Skip to content

Commit

Permalink
chore : code rabbit suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Xitija committed Sep 26, 2024
1 parent e05f7d4 commit a693b9b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/common/pipes/event-validation.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand All @@ -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,
);
Expand Down

0 comments on commit a693b9b

Please sign in to comment.