UNPKG

tiny-types

Version:

A tiny library that brings Tiny Types to JavaScript and TypeScript

27 lines 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isInRange = isInRange; const and_1 = require("./and"); const isGreaterThanOrEqualTo_1 = require("./isGreaterThanOrEqualTo"); const isLessThanOrEqualTo_1 = require("./isLessThanOrEqualTo"); /** * @desc Ensures that the `value` is greater than or equal to the `lowerBound` and less than or equal to the `upperBound` * * @example * import { ensure, isInRange, TinyType } from 'tiny-types'; * * class InvestmentLengthInYears extends TinyType { * constructor(public readonly value: number) { * super(); * ensure('InvestmentLengthInYears', value, isInRange(1, 5)); * } * } * * @param {number} lowerBound * @param {number} upperBound * @returns {Predicate<number>} */ function isInRange(lowerBound, upperBound) { return (0, and_1.and)((0, isGreaterThanOrEqualTo_1.isGreaterThanOrEqualTo)(lowerBound), (0, isLessThanOrEqualTo_1.isLessThanOrEqualTo)(upperBound)); } //# sourceMappingURL=isInRange.js.map