1.0.6 • Published 1 year ago

nuban v1.0.6

Weekly downloads
493
License
MIT
Repository
github
Last release
1 year ago

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

1.0.6

1 year ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago