ukbankcheck
Catch mistyped UK bank details before a payment fails. A typed, dependency-free Python library that validates sort codes and account numbers using Vocalink's modulus-checking rules.
| Problem | A wrong digit in a sort code or account number means a failed Direct Debit, a fee and a chasing email. |
| Solution | Validate the details at entry time with the same algorithm UK banks publish. |
| Shows | Python packaging, semantic versioning, property-based testing, strict typing, CI/CD to PyPI |
| Stack | Python · uv · hatchling · pytest · Hypothesis · mypy --strict · ruff · GitHub Actions |
python -m ukbankcheck download # once: fetch Vocalink's latest tables
python -m ukbankcheck check 08-99-99 66374958
# 08-99-99 66374958: valid
from ukbankcheck import check, Outcome
result = check("08-99-99", "66374959") # one digit wrong
result.valid # False
result.outcome # Outcome.INVALID
check("12-34-56", "12345678").outcome # Outcome.NOT_CHECKED: no rules for this sort code
Engineering highlights
- Verified against the official test suite. All 34 of Vocalink's published test cases run in CI against freshly downloaded tables, covering every method and all 14 exceptions. (tests/test_spec_cases.py)
- Found a contradiction in the spec. The flowchart says exception 5 passes if either check passes; the test cases require both. I followed the tests, and a planted-bug run confirmed cases 23–25 catch the flowchart version. (decision 0003)
- "Unknown" isn't "valid". Results say whether a check actually ran (
NOT_CHECKED,FOREIGN_CURRENCY) instead of collapsing everything intoTrue. - Safe data updates. Vocalink's tables are downloaded, parsed and validated (sorted, no overlapping ranges) before being written atomically, so a bad download can't replace a good copy. (decision 0002)
- Property-based tests. Alongside normal examples, Hypothesis generates hundreds of random inputs per run to prove rules like "formatting never changes the result" and "normalising twice equals normalising once". (tests/test_properties.py)
- Caught a real edge case.
"١٢٣٤٥٦"(Arabic-Indic digits) passes Python'sstr.isdigit(); the library rejects it explicitly. - Tested on four Python versions in CI, with a 90% coverage gate (currently 100%).
- Token-free releases. Tagging
v*publishes to PyPI through trusted publishing, so no long-lived API key is stored anywhere. (decision 0001)
Build progress
- Input normalisation and shape checks
- CI on Python 3.10–3.13, release workflow
- Table download with validation (decision 0002)
- Standard, double alternate and all 14 exceptions; 34/34 spec cases pass
-
v0.1.0on PyPI - Batch checker in the browser: upload a CSV, get results back, data never leaves the page (decision 0004)
- Nine- and ten-digit account numbers (bank-specific conversions)
How I worked
New to modulus checking? Start with how it works. Every design choice has a short decision record covering the options considered and why one won. The glossary is my own explanation of each concept, with examples from this code.
Part of a portfolio: this library is used by migration-toolkit to flag bad bank details during a CRM migration. See all projects on my profile.
Run locally
Needs uv.
make install # create .venv and install dev tools
make tables # download Vocalink's tables into .vocalink/ (gitignored)
make check # ruff, mypy --strict, pytest with coverage
Metadata
Release files for ukbankcheck 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ukbankcheck-0.1.0.tar.gz | 97.0 kB | With provenance | Details for ukbankcheck-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ukbankcheck-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for ukbankcheck-0.1.0-py3-none-any.whl |
Total release size: 109.8 kB
Release files / ukbankcheck-0.1.0.tar.gz
| Download URL | ukbankcheck-0.1.0.tar.gz |
|---|---|
| Size | 97.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
761ee6e4e94b491a9edb65e1bccce2ddd4a1bc1c016daced63486fb567d41f61
|
|
BLAKE2b-256 checksum How to use checksums |
923678bdb1b45790ddafa949826de8f39a88f4a4bcde18ef6e3ba2e1800f5fc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / ukbankcheck-0.1.0-py3-none-any.whl
| Download URL | ukbankcheck-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46cfe84c13db8d37d457cdfa2dea8077254cf77374bca7d7a93c86e02f90a3c9
|
|
BLAKE2b-256 checksum How to use checksums |
4b9085430d7a072c848be4640f1426ae586439c527362fd3d86592a5901d2594
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logSecurity for ukbankcheck 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ukbankcheck-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.