Skip to content

Add New Zealand Business Number (NZBN) validation - #518

Open
ryanduguid wants to merge 1 commit into
arthurdejong:masterfrom
ryanduguid:feat/nzbn-validation
Open

ryanduguid wants to merge 1 commit into
arthurdejong:masterfrom
ryanduguid:feat/nzbn-validation

Conversation

@ryanduguid

@ryanduguid ryanduguid commented Sep 30, 2026 •

Copy link
Copy Markdown

Summary

Add stdnum.nz.nzbn for New Zealand Business Numbers, with compact(), validate() and is_valid(). Validation reuses EAN normalisation and the GS1 checksum, checking digits, length 13 and the documented 942 prefix 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 narrower 9429 seen in common examples. It does not confirm NZBN assignment or perform online lookups.

Closes #105.

Evidence

  • Before: get_cc_module('nz', 'nzbn') returns None, and importing the module raises ImportError on master 006192e.

  • 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,headers passes. 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 942 description; 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add validation for New Zealand Business Number (NZBN)

1 participant