Skip to content

Commit

Permalink
Disallow mismatching length for isDate
Browse files Browse the repository at this point in the history
  • Loading branch information
sonikishan committed Oct 23, 2024
1 parent 12b27a2 commit e08911c
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 @@ -13998,6 +13998,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 e08911c

Please # to comment.