Skip to content

Python validation library for Swedish bank account numbers

License

Notifications You must be signed in to change notification settings

hbldh/bankkonto

Repository files navigation

Bankkonto

https://coveralls.io/repos/github/hbldh/bankkonto/badge.svg?branch=master

A tool for cleaning, parsing and ultimately validating Swedish bank account numbers, primarily written to be used for web applications with form data.

Installation

$ pip install git+https://github.com/hbldh/bankkonto.git@master

Documentation

Will be available on ReadTheDocs eventually.

Usage

Direct usage for validating a bank account number:

>>> import bankkonto
>>> bankkonto.validate('9029', '5735211')
True
>>> bankkonto.validate('9029', '5735214')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hbldh/Repos/bankkonto/account.py", line 117, in validate
    bank_account_number, bank_name, bank_account_number[-1]))
bankkonto.exceptions.BankkontoValidationError: Bank account number 5735214 for Länsförsäkringar Bank has invalid control digit: 4

Clean a entered string containing both clearing number and bank account number:

>>> import bankkonto
>>> cn, bn = bankkonto.clean_and_split('8156-6 111.222.333-2')
>>> print(cn)
'81566'
>>> print(bn)
'1112223332'
>>> bankkonto.validate(cn, bn)
True

There is also a WTForms validator at bankkonto.flask.BankkontoValidator that can be used with e.g. Flask-WTF.

Tests

Run with pytest:

$ py.test tests/ --cov bankkonto --cov-report term-missing

About

Python validation library for Swedish bank account numbers

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages