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.
1 lines • 1.2 kB
Source Map (JSON)
{"version":3,"sources":["../src/asserts/date/index.ts"],"sourcesContent":["import { WithBGuardType } from '../../commonTypes';\nimport { ctxSymbol } from '../../helpers/constants';\nimport { CommonSchema, ValidatorContext } from '../../core';\n\n/**\n * @description Creates a new schema for validating date values.\n * @returns {WithBGuardType<DateSchema, Date>} A new instance of `DateSchema` for validating booleans.\n * @example\n * const schema = date();\n * parseOrFail(schema, true); // Validates successfully\n * parseOrFail(schema, 'true'); // Throws a validation error\n *\n * @instance Of DateSchema\n */\nexport function date(): WithBGuardType<DateSchema, Date> {\n return new DateSchema({ type: ['object'], requiredValidations: [] }) as WithBGuardType<DateSchema, Date>;\n}\n\nclass DateSchema extends CommonSchema {\n protected _date = 1;\n\n constructor(ctx: ValidatorContext) {\n super(ctx);\n this[ctxSymbol].date = true;\n }\n}\n"],"mappings":";;;;;;;;AAcO,SAAS,OAAyC;AACvD,SAAO,IAAI,WAAW,EAAE,MAAM,CAAC,QAAQ,GAAG,qBAAqB,CAAC,EAAE,CAAC;AACrE;AAEA,IAAM,aAAN,cAAyB,aAAa;AAAA,EAC1B,QAAQ;AAAA,EAElB,YAAY,KAAuB;AACjC,UAAM,GAAG;AACT,SAAK,SAAS,EAAE,OAAO;AAAA,EACzB;AACF;","names":[]}