Skip to content

Reject Norwegian org numbers not starting with 8 or 9 - #523

Open
mjanthony819 wants to merge 2 commits into
arthurdejong:masterfrom
mjanthony819:patch-1
Open

mjanthony819 wants to merge 2 commits into
arthurdejong:masterfrom
mjanthony819:patch-1

Conversation

@mjanthony819

Copy link
Copy Markdown

stdnum.no.orgnr accepts any 9-digit number with a valid modulus 11 check digit, so numbers like 100 000 008 validate successfully. Norwegian organisation numbers are only assigned from number series starting with 8 or 9.

Official sources:

Reject numbers whose first digit is not 8 or 9 with InvalidComponent. The modulus 11 algorithm is unchanged. stdnum.no.mva delegates to this validator, so Norwegian VAT numbers inherit the stricter check.

Eight new regression cases pair a valid check digit with an invalid leading digit (0-7); all are accepted before the change and rejected after. Two constructed numbers starting with 8 and 9 confirm valid numbers remain accepted, alongside ten real numbers found online.

Validation on Python 3.10:

  • All 414 configured tests and doctests pass (9 skipped), with the required 100% coverage maintained.
  • Repository-wide flake8 passes.
  • mypy reports no new errors.
  • scripts/check_headers.py passes.

Fixes #275.

AI assistance covered research, implementation, tests and this description.

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.

Norwegian orgnr validates invalid org numbers.

1 participant