A tool for cleaning, parsing and ultimately validating Swedish bank account numbers, primarily written to be used for web applications with form data.
Will be available on ReadTheDocs eventually.
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:
There is also a WTForms validator at bankkonto.flask.BankkontoValidator
that can be used with e.g. Flask-WTF.
Run with pytest
:
$ py.test tests/ --cov bankkonto --cov-report term-missing