United Kingdom bank tools

Build Status

Ruby gem to validate United Kingdom sort codes and bank account numbers.

When in doubt, this library aims to err on the side of allowing too much.

If we got anything wrong, please file an issue or contribute a fix yourself.

Usage

# Sort code

sort_code = BankTools::GB::SortCode.new("60-16-13")
sort_code.valid?  # => true
sort_code.errors  # => []

bad_sort_code = BankTools::GB::SortCode.new("1X")
bad_sort_code.valid?  # => false
bad_sort_code.errors  # => [ :too_short, :invalid_characters ]

# Account

 = BankTools::GB::Account.new("31926819")
.valid?  # => true
.errors  # => []

 = BankTools::GB::Account.new("1")
.valid?  # => false
.errors  # => [ :too_short ]

Installation

Add this line to your application's Gemfile:

gem "banktools-gb"

And then execute:

$ bundle

Or install it yourself as:

$ gem install banktools-gb

Tests

bundle
rspec  # or: rake

Also see

Credits

License

The gem is available as open source under the terms of the MIT License.