You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All norwegian org numbers must be between 800_000_000 and 999_999_999, and your library validates org numbers like "100 000 008". Perhaps a better validation function would be, e.g.
defis_valid(orgnr):
ifisinstance(orgnr, str):
orgnr=int(orgnr.replace(" ", "")) # Strip whitespaceelifnotisinstance(orgnr, int):
raiseTypeError("orgnr must be a str or int.")
ifnot800_000_000<=orgnr<1_000_000_000:
returnFalse# Fast way to calculate the checksumweighted_sum=0forweightin [1, 2, 3, 4, 5, 6, 7, 2, 3]:
orgnr, remainder=divmod(orgnr, 10)
weighted_sum+=weight*remainderreturnnotweighted_sum%11
Activity
arthurdejong commentedon Sep 26, 2021
Hi @LPAiken,
Thanks for reporting this. Do you have a reference somewhere to this extra check? It doesn't seem to be mentioned on https://no.wikipedia.org/wiki/Organisasjonsnummer, https://nn.wikipedia.org/wiki/Organisasjonsnummer or https://www.brreg.no/om-oss/oppgavene-vare/alle-registrene-vare/om-enhetsregisteret/organisasjonsnummeret/.