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) 875 B
import { RequiredValidation } from '../../core.mjs'; import '../../commonTypes.mjs'; import '../../InferType.mjs'; import '../../helpers/constants.mjs'; /** * @description Asserts that a number value is positive (greater than zero). * @returns {RequiredValidation} A validation function that takes a received number and an exception context. * @throws {ValidationError} if the received value is not positive. * @example * const schema = number().custom(positive()); * parseOrFail(schema, 10); // Valid * parseOrFail(schema, 0); // Throws an error: 'The received value is not a positive number' * parseOrFail(schema, -5); // Throws an error: 'The received value is not a positive number' * * @translation Error Translation Key = 'n:positive' */ declare const positive: { (): RequiredValidation; key: string; message: string; }; export { positive };