Skip to content

Utilities for working with ABA RTNs.

License

Notifications You must be signed in to change notification settings

schultz-is/rtnutil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rtnutil

Test GoDoc Go Report Card License

This package provides utilities for working with American Bankers Association routing transit numbers; also known as ABA RTNs.

More information about the composition, structure, and usage of ABA RTNs can be found on the relevant Wikipedia page1.

Installation

To install as a dependency in a go project:

go get github.com/schultz-is/rtnutil

Usage

Validating an RTN

The format and checksum of an RTN can be validated via the Validate package-level function. Note that a successful result from this function does not necessarily mean that the RTN is assigned and in use!

package main

import (
  "fmt"

  "github.com/schultz-is/rtnutil"
)

func main() {
  err := rtnutil.Validate("044000037")
  if err != nil {
    panic(err)
  }

  fmt.Println("RTN is valid!")
}

Calculating a missing RTN digit

In the case where an RTN is missing a check digit or one of the digits is illegible, it is possible to calculate the missing digit by replacing the missing digit with an "X" and passing it to the GetMissingDigit function. Only a single missing digit can be calculated this way, and the RTN provided must be missing exactly one digit.

package main

import (
  "fmt"

  "github.com/schultz-is/rtnutil"
)

func main() {
  missingDigit, err := rtnutil.GetMissingDigit("04400003X")
  if err != nil {
    panic(err)
  }

  fmt.Printf("the missing digit is %d", missingDigit)
}

Testing

Unit tests can be run and test coverage can be viewed via the provided Makefile.

make test
make coverage

Footnotes

  1. https://en.wikipedia.org/wiki/ABA_routing_transit_number

About

Utilities for working with ABA RTNs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published