The isDate
function checks if the input string is a valid date.
The function can be imported using ES6 syntax from the "multiform-validator" package:
import { isDate } from 'multiform-validator';
Alternatively, you can import the function using CommonJS syntax with require
(Node.js):
const { isDate } = require('multiform-validator');
The function takes one parameter:
value
(string) - The input string representing the date// Example 1 - Valid date
const result1 = isDate("1999-12-31");
console.log(result1); // true
// Example 2 - Valid date
const result2 = isDate("2021-01-01");
console.log(result2); // true
// Example 3 - Invalid date
const result3 = isDate("1234 5678 9012 3456");
console.log(result3); // false
The function expects the input value to be passed as a string.