# Validating Routing Number

The documentation states:

A bank routing number that identifies a bank or credit union in the U.S. Note: Validation of the routing number includes: a checksum, the first two digits of the routing number must fall within the range “01” through “12”, or “21” through “32”, and the string value must consist of nine digits.

I have a function in C# that validates routing numbers. I am still working on it, but I need test routing numbers I can test with. I was wondering if anyone has a list (probably more that 15) of both valid and invalid routing numbers?

In case my validation function could be useful to anyone, I’ll share what I have so far:

``````private static bool ValidateRoutingNumber(string routingNum)
{
int checkSum = 0;
int len = 0;
int sum = 0;
int mod = 0;

len = routingNum.Length;

var firstTwoDigits = Int32.Parse(routingNum.Substring(0, 2));
if (Enumerable.Range(01, 12).Contains(firstTwoDigits) || Enumerable.Range(21, 32).Contains(firstTwoDigits))
return false;

if (len != 9)
{
return false;
}
else
{
var result = routingNum.Substring(routingNum.Length - 1);
checkSum = Int32.Parse(result);

sum = (7 * (Int32.Parse("" + routingNum) + Int32.Parse("" + routingNum) +
Int32.Parse("" + routingNum))) +
(3 * (Int32.Parse("" + routingNum) + Int32.Parse("" + routingNum) +
Int32.Parse("" + routingNum))) +
(9 * (Int32.Parse("" + routingNum) + Int32.Parse("" + routingNum)));

mod = sum % 10;

if (mod == checkSum)
return true;
else
return false;
}
}
``````

Hi Ethan! Not the exact thing you’re looking for, but you should be able to try any routing number in the US (many banks post their Routing numbers online) to pass the check. Here’s an example routing number that works in Sandbox: 222222226.

As for Routing numbers that don’t work, you can try 123456789, and other combinations of numbers that don’t fit the check.

1 Like