fix: accept numbers written with their usual separators (se, cl, uy) - #165
Merged
Merged
Conversation
clean() in these four modules does not normalise the input to the shape validate()'s length check expects. se/personnummer required the -/+ separator, so the bare 10 and 12 digit forms were InvalidLength even though format() accepted them. The separator is written between the birth date and the birth number, it is not part of the number (Folkbokforingslagen 1991:481 §18); python-stdnum inserts the default '-' for those two lengths in compact() and that step was not ported. cl/rut, uy/cedula and uy/nie did not strip the '.' that their own format() emits, so each rejected its own standard presentation.
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
koblas
approved these changes
Aug 1, 2026
Contributor
Author
|
Thanks for the review. The branch is ready to merge. |
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.
clean()in four modules doesn't normalise the input to the shapevalidate()'s length check expects, so each rejects the identifier as it is normally written.se/personnummerrequires the separator, so the bare 10- and 12-digit forms areInvalidLength— thoughformat()has always accepted them:Per Folkbokföringslagen (1991:481) §18 the number contains "födelsetid, födelsenummer och kontrollsiffra" — the hyphen is written between them (and becomes
+the year someone turns 100), so it isn't part of the number.python-stdnum'sse.personnummer.compact()inserts the default-at those two lengths; that step wasn't ported. Finishes #97 on thevalidate()side.cl/rut,uy/cedula,uy/niedon't strip the.their ownformat()emits, sovalidate(format('125319092')),validate(format('12345672'))andvalidate(format('912345670'))are allInvalidLength.These are the only four: I checked all 198 modules by re-running every valid example in the specs through
python-stdnumin 8 written forms, byvalidate(format(x))/validate(compact(x)), and by feedingpython-stdnum's canonicalformat()back in. All three probes are empty afterwards. Where the port is deliberately ahead ofpython-stdnumI left it —tw/ubn(#159) and samordningsnummer, which upstream still rejects.Tests reuse existing fixtures with only the separator changed, plus a bad check digit in each new form.
npm test1627 pass (+17); themx/curpfailure is pre-existing onmain.