niho/personal-number/1.0.0

NOTE: the latest version is 1.2.1

PersonalNumber.Swedish

Parse Swedish personal numbers. Supports both ordinary "personnummer" and "sammordningsnummer" assigned to foreign temporary visitors.

Definition

An opaque type representing a valid personal number.

Check if the personal number is a "personnummer".

Check if the personal number is a "sammordningsnummer".

Errors

= InvalidFormat
| InvalidLength
| InvalidDate
| InvalidChecksum

If the parsing fails an error of this type is returned.

Strings

Parse a string into a personal number.

Converts a personal number to string representation in the long format that is commonly used for database storage (YYYYMMDDXXXX).

Format a personal number into a user readable string (YYYYMMDD-XXXX).

JSON

Decode a personal number.

Encode a personal number into a JSON value.