UNPKG

indicative-utils

Version:

Reusable utilities for indicative validation library

14 lines (13 loc) 374 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function toDate(value) { if (value instanceof Date) { return value; } if (typeof (value) !== 'string') { return null; } const castedValue = new Date(value); return (castedValue.toString() === 'Invalid Date') ? null : castedValue; } exports.toDate = toDate;