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.
26 lines (23 loc) • 1.01 kB
text/typescript
import { RequiredValidation } from '../../core.mjs';
import '../../commonTypes.mjs';
import '../../InferType.mjs';
import '../../helpers/constants.mjs';
/**
* @description Asserts that a number value is not less than a specified minimum value.
* @param {Date | string} expected The minimum allowable value.
* @returns {RequiredValidation} A validation function that takes a received Date or string and an exception context.
* @throws {ValidationError} if the received value is less than the expected minimum value.
* @example
* const schema = date().custom(dateMin('2023-01-01'));
* parseOrFail(schema, new Date('2023-01-02')); // Valid
* parseOrFail(schema, new Date('2023-01-01')); // Valid
* parseOrFail(schema, new Date('2022-12-31')); // Throws an error: 'The received value is less than expected'
*
* @translation Error Translation Key = 'dt:min'
*/
declare const dateMin: {
(expected: Date | string): RequiredValidation;
key: string;
message: string;
};
export { dateMin };