isValidDate()
const isValidDate: (value, format) => string;
Validates that a date string matches the specified format and represents a valid date
Parameters
| Parameter | Type | Description |
|---|---|---|
value | string | The date string to validate |
format | string | The expected date format (currently only supports "MM/DD/YY") |
Returns
string
Empty string if valid, error message if invalid
Example
isValidDate("02/30/23", "MM/DD/YY") // Returns: "Please enter a valid date."
isValidDate("13/01/23", "MM/DD/YY") // Returns: "Please enter a valid date in MM/DD/YY format."
isValidDate("12/31/23", "MM/DD/YY") // Returns: ""