Add New Zealand Business Number (NZBN) validation - #518
Open
ryanduguid wants to merge 1 commit into
Open
ryanduguid wants to merge 1 commit into
ryanduguid wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
stdnum.nz.nzbnfor New Zealand Business Numbers, withcompact(),validate()andis_valid(). Validation reuses EAN normalisation and the GS1 checksum, checking digits, length 13 and the documented942prefix in that order.The official API documentation specifies the length and check digit; Companies Office guidance specifies
942. The module accepts that prefix without requiring the narrower9429seen in common examples. It does not confirm NZBN assignment or perform online lookups.Closes #105.
Evidence
Before:
get_cc_module('nz', 'nzbn')returnsNone, and importing the module raisesImportErroron master006192e.After: 415 tests pass with 100% branch coverage on Windows CPython 3.8 to 3.14 and Linux CPython 3.14; nine conditional tests skip on each run. The new module covers all 20 statements and six branches.
Linux
tox -e py314,flake8,mypy,docs,headerspasses. Mypy checks the declared Python 3.9 to 3.14 targets. Windows flake8 also passes with UTF-8 enabled.Doctests include 20 public corporate NZBNs from the Peppol Directory, a separate official API example, normalisation and failure cases. Sources and collection date are recorded; synthetic cases make no assignment claim.
Source archive and wheel contain the exact module bytes. Fresh installed-package checks confirm country-module discovery and the existing NZ VAT alias, including a fresh wheel install on Python 3.8.
Upstream: Test workflow passes CPython 3.8 to 3.14, PyPy 3.9, lint, mypy, docs, headers and CodeQL. All 14 check runs on the published head report success.
Merge danger
Door: two-way. Blast radius: NZBN callers and module catalogues.
This adds a module and its doctests. Existing validators, aliases, dependencies and release documentation are unchanged. Prefix enforcement follows the current published
942description; it does not establish registration status.Unverified
macOS was not tested. Local checks covered Windows CPython 3.8 to 3.14 and Linux CPython 3.14; upstream CI covers the remaining declared Linux matrix, including PyPy 3.9. Live registry assignment is outside this module's scope.
The unchanged Windows checks have platform issues: default text decoding fails in flake8 and the header script. With UTF-8 enabled, flake8 passes; the header script reports 15 identification failures in unchanged update scripts and flags neither added file. Linux's complete header check passes.