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.

25 lines (22 loc) 914 B
import { RequiredValidation } from '../../core.mjs'; import '../../commonTypes.mjs'; import '../../InferType.mjs'; import '../../helpers/constants.mjs'; /** * @description Asserts that a string is a valid date in the format YYYY-MM-DD. * @returns {RequiredValidation} A validation function that takes a received string and an exception context. * @throws {ValidationError} if the received string is not a valid date. * @example * const schema = string().custom(isValidDate()); * parseOrFail(schema, "2020-01-01"); // Valid * parseOrFail(schema, "2020-1-1"); // Throws an error: 'The received value is not a valid date' * parseOrFail(schema, "2020-01-32"); // Throws an error: 'The received value is not a valid date' * * @translation Error Translation Key = 's:isValidDate' */ declare const isValidDate: { (): RequiredValidation; key: string; message: string; }; export { isValidDate };