From 76dd2329f39a27f490b64580eb807b4f9de970e1 Mon Sep 17 00:00:00 2001 From: Andrew Radulescu Date: Fri, 20 Sep 2024 12:57:09 +0300 Subject: [PATCH] fix: [Contracts] Fix date check on create contract DTO --- .../documents/dto/create-document-contract.dto.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/src/api/documents/dto/create-document-contract.dto.ts b/backend/src/api/documents/dto/create-document-contract.dto.ts index 75180641..bc5e2948 100644 --- a/backend/src/api/documents/dto/create-document-contract.dto.ts +++ b/backend/src/api/documents/dto/create-document-contract.dto.ts @@ -7,9 +7,16 @@ export class CreateDocumentContractDto { documentNumber: string; @IsDate() - @MinDate(() => new Date(), { - message: 'Document date must be greater than or equal to the current date', - }) + @MinDate( + () => { + const today = new Date(); + return new Date(today.getFullYear(), today.getMonth(), today.getDate()); + }, + { + message: + 'Document date must be greater than or equal to the current date', + }, + ) documentDate: Date; @IsDate()