UNPKG

@vitruvius-labs/ts-predicate

Version:
10 lines (9 loc) 422 B
import { assertInteger } from "../../../type-assertion/assert-integer.mjs"; import { ValidationError } from "../../../type-assertion/utils/validation-error.mjs"; function assertBetween(value, min, max) { assertInteger(value); if (value < min || max < value) { throw new ValidationError(`Value ${value.toFixed(0)} is not between ${min.toFixed(0)} and ${max.toFixed(0)}.`); } } export { assertBetween };