class-validator-extended
Version:
Additional validators for class-validator.
16 lines (15 loc) • 574 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.maxBigInt = maxBigInt;
const is_bigint_1 = require("../../type/is-bigint");
/**
* @category Predicates
* @param value The value to validate.
* @param maximum The maximum allowed value.
*/
function maxBigInt(value, maximum) {
if (!(typeof maximum === 'bigint' || (typeof maximum === 'number' && Number.isFinite(maximum)))) {
throw new TypeError('Parameter "maximum" must be a finite number');
}
return (0, is_bigint_1.isBigInt)(value) && value <= BigInt(maximum);
}