From 8a49a1746e60da951b7e177c8f5d631886df96c5 Mon Sep 17 00:00:00 2001 From: sumit joshi <47482270+Sumit-tech-joshi@users.noreply.github.com> Date: Sat, 23 Mar 2024 18:14:39 -0700 Subject: [PATCH 1/3] Add validation Hyphen before year is not allowed --- src/lib/isDate.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/isDate.js b/src/lib/isDate.js index f0b28917a..dc69b3bc1 100644 --- a/src/lib/isDate.js +++ b/src/lib/isDate.js @@ -22,7 +22,7 @@ function zip(date, format) { } export default function isDate(input, options) { - if (typeof options === 'string') { // Allow backward compatbility for old format isDate(input [, format]) + if (typeof options === 'string') { // Allow backward compatibility for old format isDate(input [, format]) options = merge({ format: options }, default_date_options); } else { options = merge(options, default_date_options); @@ -49,6 +49,11 @@ export default function isDate(input, options) { let fullYear = dateObj.y; + // Check if the year starts with a hyphen + if (fullYear.startsWith('-')) { + return false; // Hyphen before year is not allowed + } + if (dateObj.y.length === 2) { const parsedYear = parseInt(dateObj.y, 10); From 55257398b37023010aa28e881af300aa51022b09 Mon Sep 17 00:00:00 2001 From: sumit joshi <47482270+Sumit-tech-joshi@users.noreply.github.com> Date: Thu, 28 Mar 2024 23:14:08 -0700 Subject: [PATCH 2/3] Add email regex for email issue --- src/lib/isEmail.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/isEmail.js b/src/lib/isEmail.js index 12938765e..ecd88d106 100644 --- a/src/lib/isEmail.js +++ b/src/lib/isEmail.js @@ -20,7 +20,8 @@ const default_email_options = { /* eslint-disable max-len */ /* eslint-disable no-control-regex */ const splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+) Date: Thu, 28 Mar 2024 23:14:56 -0700 Subject: [PATCH 3/3] Reverted date change --- src/lib/isDate.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/lib/isDate.js b/src/lib/isDate.js index dc69b3bc1..22b644bec 100644 --- a/src/lib/isDate.js +++ b/src/lib/isDate.js @@ -49,11 +49,6 @@ export default function isDate(input, options) { let fullYear = dateObj.y; - // Check if the year starts with a hyphen - if (fullYear.startsWith('-')) { - return false; // Hyphen before year is not allowed - } - if (dateObj.y.length === 2) { const parsedYear = parseInt(dateObj.y, 10);