n-digit-token
Version:
Cryptographically secure pseudo-random token of n digits
16 lines (15 loc) • 507 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateLength = void 0;
/**
* Validates input length.
* Throws an error if length is not a positive integer.
* @param {number} length
* @throws {error} if not called with a positive integer
*/
const validateLength = (length) => {
if (!Number.isInteger(length) || length <= 0) {
throw new Error('Invalid length: must be called with a positive integer.');
}
};
exports.validateLength = validateLength;