class-validator-extended
Version:
Additional validators for class-validator.
16 lines (15 loc) • 511 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.mapSize = mapSize;
const is_map_1 = require("../../type/is-map");
/**
* @category Predicates
* @param value The value to validate.
* @param size The size of the map that is allowed.
*/
function mapSize(value, size) {
if (typeof size !== 'number' || !Number.isFinite(size)) {
throw new TypeError('Parameter "size" must be a finite number');
}
return (0, is_map_1.isMap)(value) && value.size === size;
}