Giter Club home page Giter Club logo

nz-bank-account-validator's Introduction

NZ Bank Account Validator

v0.0.4 - A small, zero dependency Javascript NZ bank account validation library that runs everywhere.

It is based on the documentation provided by the Inland Revenue Department. This library is not however affiliated with or endorsed by the IRD.

Getting Started

Using npm:

$ npm i --save nz-bank-account-validator

Using yarn:

$ yarn add nz-bank-account-validator

Installation

In a browser: (See examples/browser.html for code example)

<script type="text/javascript" src="NZ-Bank-Account-Validator.min.js"></script>
<script type="text/javascript">
  var bankAccountValidator = window['NZ-Bank-Account-Validator'];

  bankAccountValidator.validate('01-902-0068389-00');
</script>

In Node.js (require):

const bankValidator = require('nz-bank-account-validator/lib/NZ-Bank-Account-Validator');

bankValidator.validate('01-902-0068389-00');
// => true

ES6 Modules:

import bankValidator from 'nz-bank-account-validator/lib/NZ-Bank-Account-Validator';

bankValidator.validate('01-902-0068389-00');
// => true

Usage

const bankValidator = require('nz-bank-account-validator/lib/NZ-Bank-Account-Validator');

bankValidator.getId('01-902-0068389-00'); // '01'
bankValidator.getBranch('01-902-0068389-00'); // '02'
bankValidator.getBase('01-902-0068389-00'); // '0068389'
bankValidator.getSuffix('01-902-0068389-00'); // '00'

bankValidator.getPartsObject('01-902-0068389-00'); // { id: '01', branch: '902', base: '0068389', suffix: '00' }

bankValidator.validate('01-902-0068389-00') // true
bankValidator.validate({ id: '01', branch: '902', base: '0068389', suffix: '00' }) // true

bankValidator.validate('01-902-XXXXX-00') // false
bankValidator.validate('01-902--00') // false
bankValidator.validate('01-902-123456-00') // false

Running the tests

To run the tests locally:

npm i
npm run tests

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

References

nz-bank-account-validator's People

Contributors

digime99 avatar kiwi-josh avatar ollyfg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nz-bank-account-validator's Issues

Module not found using Yarn as my package manager

Thank you for this awesome package. I'm having this error when importing.

Module not found: Can't resolve 'nz-bank-account-validator'

Has anyone encountered this error? I've got more than a dozen of packages installed, only this package is throwing the error on my end. I'm using [email protected].

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.