UNPKG

bguard

Version:

**bguard** is a powerful, flexible, and type-safe validation library for TypeScript. It allows developers to define validation schemas for their data structures and ensures that data conforms to the expected types and constraints.

12 lines (9 loc) 982 B
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/helpers/isValidDateInner.ts function isValidDateInner(d) { return ( // @ts-expect-error we expect d to have getTime method Object.prototype.toString.call(d) === "[object Date]" && !isNaN(typeof _optionalChain([d, 'optionalAccess', _ => _.getTime]) === "function" && d.getTime()) ); } exports.isValidDateInner = isValidDateInner; //# sourceMappingURL=chunk-VBTWYDEM.js.map