New format types
Type of change
- [x] New feature
- [ ] Bug fix
- [ ] Security patch
- [ ] Documentation update
Description
Adds two new ways to format personnummer:
Now there are four versions to format a personnummer:
- short: 4103219202
- long: 194103219202
- separatedShort: 410321-9202
- separatedLong: 19410321-9202
I've also made sure to support the old version to call the format function. It can still be called with a boolean and you will get the same format as the function would give before this change.
Motivation
I needed to format a personnummer in a different way than the two previous ways to format. There are 4 different common formats I see on personnummer and this package only supports two of them.
Considerations
the function right now takes a string as an argument Personnummer.parse("194103219202").format("separatedLong"). This might be better achieved with an enum or a separate "format class" which has a method to handle formatting.
Checklist
- [x] I have read the CONTRIBUTING document.
- [x] I have read and accepted the Code of conduct
- [x] Tests passes.
- [x] Style lints passes.
- [x] Documentation of new public methods exists.
- [x] New tests added which covers the added code.
- [x] Documentation is updated.
- [ ] This PR includes breaking changes.
I couldn't find any CONTRIBUTING document or style lints / documentation. I selected them because I'm worried I would get automatically rejected otherwise. It seems like those features / documents doesn't exist? Is this just a standard PR template?
I've just read this page about how the package should be structured. This change doesn't conform to the rest of the packages. This feature request is perhaps better suited as a proposed v4 or v3.1 of the specification.
Hey, first off all - great work!
But as know we have a specification that every package is following to the best of its ability. For new stuff we like you to open an issue in meta with a proposal (or just the idea). We have talked internally a bit about this and one idea is to have options for the format method or/and accept a format template string so you can format in different ways.
Not all formats you are talking about is standard formats, but we might need to support them too.
But please open an issue in meta and we can talk there and we can keep this pull request open (it will be low activity a few weeks forward due to vacations).
Closing due to no issue in meta in meta, feel free to open an issue and we can continue the talk of new format types, but for now we will focus on the standard types. The history of this pull request will be available after the close.