Skip to main content

Python implementation for bank account validation.

Project description

https://travis-ci.com/filwaitman/bank-account-validator.svg?branch=master https://codecov.io/gh/filwaitman/bank-account-validator/branch/master/graph/badge.svg

Bank Account Validator

Python implementation for bank account validation.

Currently, the biggest Brazilian banks are implemented - and so being validated. There is no other countries’ banks implemented, but the code is modular and it can be done easily.

Usage:

from bank_account_validator.core import Bank
bank_class = Bank.get('bank_code', 'country_code')
bank_class(branch='branch', branch_digit='branch_digit',
           account='account', account_digit='account_digit').execute()

Examples:

from bank_account_validator.core import Bank, BrazilianBank

# Account below is correct, so nothing is raised by calling execute()
bank_class = Bank.get('237', 'BR')
bank_class(branch='1769', branch_digit='8', account='200040', account_digit='7').execute()

# Account below has invalid branch so InvalidBranch will be raised
bank_class = BrazilianBank.get('237')
bank_class(branch='1769', branch_digit='0', account='200040', account_digit='7').execute()
# InvalidBranch: Branch "1769-0" is wrong.

# Account below has invalid account so InvalidAccount will be raised
bank_class = BrazilianBank.get('237')
bank_class(branch='1769', branch_digit='8', account='200040', account_digit='0').execute()
# InvalidAccount: Account "0200040-0" is wrong.

# Sometimes there is not an unitary validation for both branch and account
# I mean, the full combination is evaluated at once.
bank_class = BrazilianBank.get('033')
bank_class(branch='2006', branch_digit='', account='01008407', account_digit='1').execute()
# InvalidBranchAndAccountCombination: Combination (branch="2006", account="01008407-1") does not match.

# It also validates wether digits must be supplied or not, as well as branch/account lengths
bank_class = BrazilianBank.get('237')
bank_class(branch='111769', branch_digit='8', account='200040', account_digit='7').execute()
# InvalidBranchlength: For bank code "237", branches length must be 4.

bank_class(branch='1769', branch_digit='8', account='11200040', account_digit='7').execute()
# InvalidAccountlength: For bank code "237", accounts length must be 7.

bank_class(branch='1769', branch_digit='', account='200040', account_digit='7').execute()
# MissingBranchDigit: For bank code "237", branches must have a digit, of length 1.

bank_class(branch='1769', branch_digit='11', account='200040', account_digit='7').execute()
# UnexpectedBranchDigit: For bank code "237", branches must have 1 digits.

bank_class(branch='1769', branch_digit='8', account='200040', account_digit='').execute()
# MissingAccountDigit: For bank code "237", accounts must have a digit, of length 1.

bank_class(branch='1769', branch_digit='8', account='200040', account_digit='11').execute()
# UnexpectedAccountDigit: For bank code "237", accounts must have 1 digits.

Contribute

Did you think in some interesting feature, or have you found a bug? Please let me know!

Of course you can also download the project and send me some pull requests.

You can send your suggestions by opening issues.

You can contact me directly as well. Take a look at my contact information at http://filwaitman.github.io/ (email is preferred rather than mobile phone).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bank-account-validator-0.2.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

bank_account_validator-0.2-py2.py3-none-any.whl (6.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file bank-account-validator-0.2.tar.gz.

File metadata

  • Download URL: bank-account-validator-0.2.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

File hashes

Hashes for bank-account-validator-0.2.tar.gz
Algorithm Hash digest
SHA256 fc1a33f05b4e88a70014bf71d193225d57c66a4ba13dfe08de9342b51d9d337c
MD5 85ad9a180dd8ca52c124a02424e468fa
BLAKE2b-256 d17fb8005802f2dc3161bae388cfbcdd7461648244fcf84736aedbb6ee587206

See more details on using hashes here.

File details

Details for the file bank_account_validator-0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: bank_account_validator-0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

File hashes

Hashes for bank_account_validator-0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 23fd68eda9a365a69509b15e9e914a88ed86f475a6f32af19565ecfaa00f23f5
MD5 e2f7fbede52ff2f2a89f898830f9aff9
BLAKE2b-256 83d2560a3367179d3dc59669999833f50d1d60b8a0b9742dd3600fb09d4afac5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page