Skip to content

Validate United Kingdom bank account numbers (with sort codes).

License

Notifications You must be signed in to change notification settings

barsoom/banktools-gb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

United Kingdom bank tools

Ruby CI

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

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

bad_account = BankTools::GB::Account.new("1")
bad_account.valid?  # => false
bad_account.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.

About

Validate United Kingdom bank account numbers (with sort codes).

Resources

License

Stars

Watchers

Forks

Packages

No packages published