Package

purescript-hetu

Repository
je-l/hetu
License
MIT
Uploaded by
je-l
Published on
2021-04-17

Personal identity code - Digi- ja väestötietovirasto

This library aims to provide a reliable way to deserialize all valid hetus. Also temporary hetus (id number >= 900) are supported.

> import Hetu
> import Data.Functor
> hetu = parseHetu "260993-5658"
> hetu
(Right { birthday: (Date (Year 1993) September (Day 26)), id: 565 })

> map gender hetu
(Right Male)

> map formatHetu hetu
(Right "260993-5658")

Detailed error messages are provided with exact reason why the hetu is not valid:

> parseHetu "280264-051E"
(Left "Invalid checksum at column 12")

> parseHetu "a60993-5658"
(Left "Expected digit at column 1")

> parseHetu "131052B308T"
(Left "Invalid century: \"B\" at column 8")

Development

Install spago and run spago test

Related projects