Skip to content

Commit fc31e6e

Browse files
sonikishanrubiin
andauthored
Disallow mismatching length for isDate (#2481)
Co-authored-by: Rubin Bhandari <roobin.bhandari@gmail.com>
1 parent a513deb commit fc31e6e

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/lib/isDate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default function isDate(input, options) {
2828
options = merge(options, default_date_options);
2929
}
3030
if (typeof input === 'string' && isValidFormat(options.format)) {
31+
if (options.strictMode && input.length !== options.format.length) return false;
3132
const formatDelimiter = options.delimiters
3233
.find(delimiter => options.format.indexOf(delimiter) !== -1);
3334
const dateDelimiter = options.strictMode

test/validators.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14001,6 +14001,7 @@ describe('Validators', () => {
1400114001
new Date([2014, 2, 15]),
1400214002
new Date('2014-03-15'),
1400314003
'29.02.2020',
14004+
'02.29.2020.20',
1400414005
'2024-',
1400514006
'2024-05',
1400614007
'2024-05-',

0 commit comments

Comments
 (0)