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.

26 lines (23 loc) 901 B
import { RequiredValidation } from '../../core.js'; import '../../commonTypes.js'; import '../../InferType.js'; import '../../helpers/constants.js'; /** * @description Asserts that a number value does not exceed a specified maximum value. * @param {number} expected The maximum allowable value. * @returns {RequiredValidation} A validation function that takes a received number and an exception context. * @throws {ValidationError} if the received value exceeds the expected maximum value. * @example * const schema = number().custom(max(100)); * parseOrFail(schema, 99); // Valid * parseOrFail(schema, 100); // Valid * parseOrFail(schema, 101); // Throws an error: 'The received value is greater than expected' * * @translation Error Translation Key = 'n:max' */ declare const max: { (expected: number): RequiredValidation; key: string; message: string; }; export { max };