A library for validating US Bank Account routing and account numbers
npm install us-bank-account-validatorUS 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.
You can install us-bank-account-validator through npm.
``sh`
npm install us-bank-account-validator
In Node/Webpack/Browserify:
`js
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
`
Will return something like this:
`js
{
// 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 are checked against MICR number format. We test this formula against a number of known routing numbers, which can be found at src/routing-to-bank-name.json.
Will return something like this:
`js
{
// 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.