Code Monkey home page Code Monkey logo

hetu's Introduction

Parsing and validation for finnish national identification number

API reference available in Pursuit: https://pursuit.purescript.org/packages/purescript-hetu

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.