Description
isDate returns false for all strings
isDate is always returning false, even for correctly formatted strings.
Examples
validator.isDate('2024-01-01', { format: 'YYYY-MM-DD', delimiters: ['-'] }); // false
validator.isDate("2024/01/01"); // false
validator.isDate(new Date('2024-01-01')); // true
validator.isDate(validator.toDate("1")); // true
The only way I was able to make the result come back true was to coerce the date into native date format with validator.isDate(new Date(${inputValue}
)) or validator.isDate(validator.toDate(inputValue)). This is not a viable workaround as the last example shows (returns valid for "1").
It seems like isDate is expecting an object, but the tool is intended for string validation.
Notably other validators like isBefore and isAfter are working correctly with the same date format YYYY/MM/DD, as a string.
Additional context
Validator.js version: 13.11.0
included via cdn: <script src="https://unpkg.com/validator@latest/validator.min.js"></script>
Node.js version: 18.16.0
OS platform: windows