Helper library when working with nuban accounts
npm install nubanHelper library when working with nuban accounts
This is a Node.js module available through the
npm registry. It can be installed using thenpm
oryarn
command line tools.
``sh`
npm install nuban --save
Use the library's validate function to confirm that the account number is valid for the bank. Format is:
`javascript`
nuban.validate(accountNumber, bankCode);
`javascript`
const valid = nuban.validate("0123456789","011");
Use the library's calculateCheckDigit function to get the check digit for a nuban account's first 9 digits.
Format is:
`javascript`
nuban.calculateCheckDigit(first9, bankCode);
Note that this function throws a NubanValidationError if either the first9 or bank code are invalid according to a
regex check so it should be called in a try block.
`javascript`
let checkDigit = null;
try {
checkDigit = nuban.calculateCheckDigit("012345678","011");
} catch(err){
console.error(err);
}
`sh`
npm install
npm test`
> nuban@1.0.6 test /Users/i/plop/nuban
> node test.js
ok
``
None
None
MIT