us-bank-account-validator
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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 17 characters. They are usually numeric but not always, which is why this is a simple length check.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    351
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    351
  • 0.2.0
    5,105
  • 0.1.0
    173

Package Sidebar

Install

npm i us-bank-account-validator

Weekly Downloads

4,669

Version

1.0.0

License

MIT

Unpacked Size

331 kB

Total Files

18

Last publish

Collaborators

  • braintree