stringzy
Version:
A versatile string manipulation library providing a range of text utilities for JavaScript and Node.js applications.
19 lines (18 loc) • 676 B
TypeScript
export declare enum DateFormats {
YYYYMMDD = "YYYYMMDD",
MMDDYYYY = "MMDDYYYY",
DDMMYYYY = "DDMMYYYY"
}
declare const VALID_SEPARATORS: readonly [".", "-", "/"];
type ValidSeparators = typeof VALID_SEPARATORS[number];
/**
* Takes a date and a format and returns whether or not the date matches the specified format.
* Optionally takes a separator that can be used instead of the default hyphen.
*
* Only accepts 2 digit month/day and 4 digit year
* @example 01-01-2000 -> True
* @example 01-1-2000 -> False
* @example 01-01-00 -> False
*/
export declare function isDate(input: string, format: DateFormats, separator?: ValidSeparators): boolean;
export {};