diff --git a/README.md b/README.md
index d75f15b27..6abba7414 100644
--- a/README.md
+++ b/README.md
@@ -90,6 +90,7 @@ Validator | Description
--------------------------------------- | --------------------------------------
**contains(str, seed [, options])** | check if the string contains the seed.
`options` is an object that defaults to `{ ignoreCase: false, minOccurrences: 1 }`.
Options:
`ignoreCase`: Ignore case when doing comparison, default false.
`minOccurences`: Minimum number of occurrences for the seed in the string. Defaults to 1.
**equals(str, comparison)** | check if the string matches the comparison.
+**isAbaRouting(str)** | check if the string is an ABA routing number for US bank account / cheque.
**isAfter(str [, options])** | check if the string is a date that is after the specified date.
`options` is an object that defaults to `{ comparisonDate: Date().toString() }`.
**Options:**
`comparisonDate`: Date to compare to. Defaults to `Date().toString()` (now).
**isAlpha(str [, locale, options])** | check if the string contains only letters (a-zA-Z).
`locale` is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'bn', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fi-FI', 'fr-CA', 'fr-FR', 'he', 'hi-IN', 'hu-HU', 'it-IT', 'ko-KR', 'ja-JP', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'si-LK', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA']` and defaults to `en-US`. Locale list is `validator.isAlphaLocales`. `options` is an optional object that can be supplied with the following key(s): `ignore` which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s.
**isAlphanumeric(str [, locale, options])** | check if the string contains only letters and numbers (a-zA-Z0-9).
`locale` is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bn', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fi-FI', 'fr-CA', 'fr-FR', 'he', 'hi-IN', 'hu-HU', 'it-IT', 'ko-KR', 'ja-JP','ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'si-LK', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphanumericLocales`. `options` is an optional object that can be supplied with the following key(s): `ignore` which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s.
diff --git a/src/index.js b/src/index.js
index 07cbbefbe..375da845a 100644
--- a/src/index.js
+++ b/src/index.js
@@ -18,6 +18,7 @@ import isTime from './lib/isTime';
import isBoolean from './lib/isBoolean';
import isLocale from './lib/isLocale';
+import isAbaRouting from './lib/isAbaRouting';
import isAlpha, { locales as isAlphaLocales } from './lib/isAlpha';
import isAlphanumeric, { locales as isAlphanumericLocales } from './lib/isAlphanumeric';
import isNumeric from './lib/isNumeric';
@@ -145,6 +146,7 @@ const validator = {
isBoolean,
isIBAN,
isBIC,
+ isAbaRouting,
isAlpha,
isAlphaLocales,
isAlphanumeric,
diff --git a/src/lib/isAbaRouting.js b/src/lib/isAbaRouting.js
new file mode 100644
index 000000000..0c6fd7fb2
--- /dev/null
+++ b/src/lib/isAbaRouting.js
@@ -0,0 +1,20 @@
+import assertString from './util/assertString';
+
+// http://www.brainjar.com/js/validation/
+// https://www.aba.com/news-research/research-analysis/routing-number-policy-procedures
+// series reserved for future use are excluded
+const isRoutingReg = /^(?!(1[3-9])|(20)|(3[3-9])|(4[0-9])|(5[0-9])|(60)|(7[3-9])|(8[1-9])|(9[0-2])|(9[3-9]))[0-9]{9}$/;
+
+export default function isAbaRouting(str) {
+ assertString(str);
+
+ if (!isRoutingReg.test(str)) return false;
+
+ let checkSumVal = 0;
+ for (let i = 0; i < str.length; i++) {
+ if (i % 3 === 0) checkSumVal += str[i] * 3;
+ else if (i % 3 === 1) checkSumVal += str[i] * 7;
+ else checkSumVal += str[i] * 1;
+ }
+ return (checkSumVal % 10 === 0);
+}
diff --git a/test/validators.test.js b/test/validators.test.js
index 239f172ca..960f3bf36 100644
--- a/test/validators.test.js
+++ b/test/validators.test.js
@@ -5138,6 +5138,26 @@ describe('Validators', () => {
});
});
+ it('should validate ABA routing number', () => {
+ test({
+ validator: 'isAbaRouting',
+ valid: [
+ '322070381',
+ '011103093',
+ '263170175',
+ '124303065',
+ ],
+ invalid: [
+ '426317017',
+ '789456124',
+ '603558459',
+ 'qwerty',
+ '12430306',
+ '382070381',
+ ],
+ });
+ });
+
it('should validate IBAN', () => {
test({
validator: 'isIBAN',