nuban

1.0.6 • Public • Published

nuban Build Status

Helper library when working with nuban accounts

Installation

This is a Node.js module available through the npm registry. It can be installed using the npm or yarn command line tools.

npm install nuban --save

Usage

The module exposes 2 functions. Samples and an explanation follows:

Validate a nuban account number against a bank's code

Use the library's validate function to confirm that the account number is valid for the bank. Format is:

    nuban.validate(accountNumber, bankCode);
    const valid = nuban.validate("0123456789","011");

Calculate check digit

Use the library's calculateCheckDigit function to get the check digit for a nuban account's first 9 digits. Format is:

    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.

    let checkDigit = null;
    try {
        checkDigit = nuban.calculateCheckDigit("012345678","011");
    } catch(err){
        console.error(err);
    }

Tests

npm install
npm test

> nuban@1.0.6 test /Users/i/plop/nuban
> node test.js
ok

Dependencies

None

Dev Dependencies

None

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i nuban

Weekly Downloads

179

Version

1.0.6

License

MIT

Unpacked Size

6.5 kB

Total Files

5

Last publish

Collaborators

  • ibrahimlawal