CoerceToValidDateValue
cartographer / coerceToValidDateValue
Function: coerceToValidDateValue()
Section titled “Function: coerceToValidDateValue()”coerceToValidDateValue(
value):string|number|Date|null
Defined in: types/types.ts:55
Coerce a field value to a valid Date constructor argument. Filters out non-date-like values and returns string | number | Date | null.
Parameters
Section titled “Parameters”A potential date value
string | number | boolean | string[] | Date | null | undefined
Returns
Section titled “Returns”string | number | Date | null
- String, number, Date, or null (suitable for Date constructor)
Example
Section titled “Example”const coerced1 = coerceToValidDateValue('2026-01-06'); // Returns: '2026-01-06'const coerced2 = coerceToValidDateValue(new Date()); // Returns: Date objectconst coerced3 = coerceToValidDateValue(true); // Returns: null (boolean not valid for Date)