Skip to content

Commit cfa11e2

Browse files
Merge pull request #47 from braintree/dynamic-rtn-validation
add function to check routing numbers dynamically
2 parents 85ad98b + eef7613 commit cfa11e2

File tree

8 files changed

+80
-19082
lines changed

8 files changed

+80
-19082
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# CHANGELOG
22

3+
## UNRELEASED
4+
5+
- Changed routing number validity from checks against static list to dynamic checking against [standard ABA RTN formats](https://en.wikipedia.org/wiki/Routing_transit_number#MICR_routing_number_format)
6+
37
## 1.0.1
48

59
- Updates (sub-)dependencies
610
- `braces` to 3.0.3
7-
- `cross-spawn` to 7.0.6
11+
- `cross-spawn` to 7.0.6
812
- `micromatch` to 4.0.8
913

1014
## 1.0.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Will return something like this:
5757
}
5858
```
5959

60-
Valid routing numbers come from a hard-coded list of possible numbers, which you can find in `src/routing-number-list.js`.
60+
Valid routing numbers are checked against [MICR number format](https://en.wikipedia.org/wiki/Routing_transit_number#MICR_routing_number_format). We test this formula against a number of known routing numbers, which can be found at `src/routing-to-bank-name.json`.
6161

6262
### `valid.accountNumber(value: string): object`
6363

package-lock.json

Lines changed: 25 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
"build": "tsc --declaration",
1616
"lint": "eslint --ext js,ts .",
1717
"posttest": "npm run lint",
18-
"test": "jest",
19-
"build-routing-list": "ts-node scripts/build-routing-list"
18+
"test": "jest"
2019
},
2120
"author": "Braintree <code@getbraintree.com> (https://www.braintreepayments.com/)",
2221
"license": "MIT",

scripts/build-routing-list.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/__tests__/routing-number.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ describe("routingNumber", () => {
5050
});
5151
});
5252

53+
it("can validate a potentially valid routing number dynamically", () => {
54+
// 645442104 is not an assigned routing number, but has a valid form
55+
expect(routingNumber("645442104")).toEqual({
56+
isValid: true,
57+
isPotentiallyValid: true,
58+
});
59+
});
60+
5361
it("is invalid for numbers that are too long", () => {
5462
["3224844012", "32248440100", "0322484401"].forEach((value) => {
5563
expect(routingNumber(value)).toEqual({
@@ -59,7 +67,7 @@ describe("routingNumber", () => {
5967
});
6068
});
6169

62-
it("is invalid for values not in the list", () => {
70+
it("is returns false for invalid routing numbers", () => {
6371
[
6472
"999999999",
6573
"074986820 ",

0 commit comments

Comments
 (0)