Skip to content
A library for validating US bank account routing and account numbers
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
scripts Update to node 10 and remove gulp requirement May 20, 2019
src
test
.eslintignore
.eslintrc Initial commit Nov 7, 2016
.gitignore
.npmignore
.nvmrc Update to node 10 and remove gulp requirement May 20, 2019
CHANGELOG.md Initial commit Nov 7, 2016
LICENSE Update license for 2017 Jan 13, 2017
README.md Remove readme reference to `card-validator` Apr 11, 2017
index.js Initial commit Nov 7, 2016
package-lock.json
package.json Update dev dependencies Aug 29, 2019

README.md

US Bank Account Validator

US Bank Account Validator provides validation utilities for US bank routing and account numbers. It includes first-class support for "potential" validity so you can use it to present appropriate UI to your user as they type.

Installation

You can install us-bank-account-validator through npm.

npm install us-bank-account-validator

Example

In Node/Webpack/Browserify:

var valid = require('us-bank-account-validator');

var routingValidation = valid.routingNumber('4111');

if (routingValidation.isValid) {
  renderFullyValidRoutingNumber();
} else if (!routingValidation.isPotentiallyValid) {
  renderInvalidRoutingNumber();
}

In the browser with <script> tags:

<script src="path/to/us-bank-account-validator.js"></script>
<script>
var accountValidation = valid.accountNumber('4111');

if (accountValidation.isValid) {
  renderFullyValidAccountNumber();
} else if (!accountValidation.isPotentiallyValid) {
  renderInvalidAccountNumber();
}
</script>

API

valid.routingNumber(value: string): object

Will return something like this:

{
  // if false, indicates there is no way the number could be valid
  isPotentiallyValid: true,

  // if true, number is fully valid for submission
  isValid: false
}

Valid routing numbers come from a hard-coded list of possible numbers, which you can find in src/routing-number-list.js.

valid.accountNumber(value: string): object

Will return something like this:

{
  // if false, indicates there is no way the number could be valid
  isPotentiallyValid: true,

  // if true, number is fully valid for submission
  isValid: false
}

Valid account numbers are strings between 4 and characters. They are usually numeric but not always, which is why this is a simple length check.

You can’t perform that action at this time.