-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] - More ways to format a personnummer #48
Comments
Hi! Thank you for the feature request. This is something we have been discussing to introduce as a new feature in the next API specification actually, the implementation we discussed was a bit more "simple", but I personally do prefer the way you mention above. I will take it up with the team and keep this post open for the discussion! |
Hi, I disagree with going down this path. In the vein of "the only thing better than perfect is spec-compliant" I see a risk where this causes more harm than good by "encouraging" these invalid formats, which in turn just fractures the "ecosystem" even more than the mess we already have. That said, if you have to go with one, I'd prefer the enum approach - at least there'd be some limit to the chaos Footnotes
|
@swantzter maybe it's not wise to support extending the formatter and creating custom formats, but i'm not sure i agree with following Swedish law is the right call for what a personnummer can look like. The other two formats I mentioned are wildly used, even though they're not officially recognised. But to encourage the use of the official formats, maybe we should name the other 2 unofficial formats to something like |
Description
Currently this package only supports two ways to format a personnummer default: 830621-9299 and long: 198306219299. In my experience, there are generally four ways that a personnummer is usually structured:
short: 8306219299
long: 198306219299
separated short: 830621-9299
separated long: 19830621-9299
My proposal is to implement a way to format personnummer in more ways that two. But more importantly make the package able to support more that two formats without breaking.
Implementation
Instead of passing a boolean to the format function you pass a format type. This should ideally be created with a class which can be extended and make it possible to create more formats down the line.
Example implementation:
And alternative implementation is using enums / strings with different format types
This solution is less extendable and doesn't allow people to implement their own format functions. However this solution is simpler and is easier to implement in language such as Bash and Haskell (I don't have very much experience in any of those languages so I'm not if the first implementation is even possible in them).
Breaking changes
Depending on how this is implemented this could be breaking. Ideally the old boolean system should be removed completely. However the old function could still be accessible either trough overloads or joint types. I would advocate to remove the old system completely since this package is rather small and it shouldn't be to complicated to migrate to the new function if you decide to update to the newest version.
The text was updated successfully, but these errors were encountered: