UNPKG

is-valid-account-number

Version:
18 lines (12 loc) 423 B
'use strict' const checkdigit = require('checkdigit') module.exports = function (accountNumber) { if (!accountNumber) { throw new Error('Missing required input: account number') } const accountnumber = accountNumber.toString().replace(/\D/g, '') if (accountnumber.length !== 11) { throw new Error('Wrong length. Account number must be 11 digits') } return checkdigit.mod11.isValid(accountnumber) }