Skip to content

Commit

Permalink
Disallow mismatching length for isDate (#2481)
Browse files Browse the repository at this point in the history
Co-authored-by: Rubin Bhandari <roobin.bhandari@gmail.com>
  • Loading branch information
sonikishan and rubiin authored Oct 27, 2024
1 parent a513deb commit fc31e6e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/isDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function isDate(input, options) {
options = merge(options, default_date_options);
}
if (typeof input === 'string' && isValidFormat(options.format)) {
if (options.strictMode && input.length !== options.format.length) return false;
const formatDelimiter = options.delimiters
.find(delimiter => options.format.indexOf(delimiter) !== -1);
const dateDelimiter = options.strictMode
Expand Down
1 change: 1 addition & 0 deletions test/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14001,6 +14001,7 @@ describe('Validators', () => {
new Date([2014, 2, 15]),
new Date('2014-03-15'),
'29.02.2020',
'02.29.2020.20',
'2024-',
'2024-05',
'2024-05-',
Expand Down

0 comments on commit fc31e6e

Please sign in to comment.