HermannBjorgvin / Kennitala

Icelandic national ID (kennitölur) utilities for servers and clients.
MIT License
36 stars 10 forks source link

Updated API to be more compatible with V1. Removed undefined return from info function #36

Open HermannBjorgvin opened 4 days ago

HermannBjorgvin commented 4 days ago

Related to #35 and another request from @eirikurn to change the API so it is more compatible with V1.

For example isPerson instead of isPersonkennitala. This reverts back to isPerson which is how it was in V1.

I also updated test cases where I added 20 as the starting increment for generatePerson. The manual addition of the starting increment in the tests caused me to miss that generatePerson sometimes generated ID's with starting increments below 20. I fixed this by making the default starting increments for persons 20.

I also removed the undefined returns from the info function where an undefined century digit at the end of a kt would return undefined. I refactored the function so it now always returns a KennitalaInfo object.

Also updated the formatKennitala function so it returns a string like before. It adds a optional spacer between the 6th and 7th digits in case the string length is longer than 5. Useful for formatting input fields.