Skip to content

Commit

Permalink
fix: use IsBeforeDate validator for ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
GloireMutaliko21 committed Nov 21, 2024
1 parent 4069dd7 commit 7308eb4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/core/src/tasks/dto/get-task-by-date-filter.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import { IsDate, IsOptional, ValidateIf } from 'class-validator';
import { Type } from 'class-transformer';
import { ITaskDateFilterInput } from '@gauzy/contracts';
import { TenantOrganizationBaseDTO } from '../../core/dto';
import { IsBeforeDate } from './../../shared/validators';

export class TaskDateFilterInputDTO extends TenantOrganizationBaseDTO implements ITaskDateFilterInput {
@ApiPropertyOptional({ type: () => Date })
@Type(() => Date)
@IsOptional()
@IsDate()
@IsBeforeDate(TaskDateFilterInputDTO, (it) => it.startDateTo, {
message: 'Start date from must be before the start date to'
})
startDateFrom?: Date;

@ApiPropertyOptional({ type: () => Date })
Expand All @@ -22,6 +26,9 @@ export class TaskDateFilterInputDTO extends TenantOrganizationBaseDTO implements
@Type(() => Date)
@IsOptional()
@IsDate()
@IsBeforeDate(TaskDateFilterInputDTO, (it) => it.dueDateTo, {
message: 'Due date from must be before the due date to'
})
dueDateFrom?: Date;

@ApiPropertyOptional({ type: () => Date })
Expand Down

0 comments on commit 7308eb4

Please sign in to comment.