Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/martinaskestad/sweden-national-id
Validation and parsing of the Swedish national identification number as well as co-ordination numbers for foreign citizens.
https://github.com/martinaskestad/sweden-national-id
national-identification-number personnummer personnummervalidering sweden
Last synced: about 2 months ago
JSON representation
Validation and parsing of the Swedish national identification number as well as co-ordination numbers for foreign citizens.
- Host: GitHub
- URL: https://github.com/martinaskestad/sweden-national-id
- Owner: MartinAskestad
- Created: 2019-06-22T08:51:18.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-18T20:00:39.000Z (over 1 year ago)
- Last Synced: 2024-10-30T14:18:21.630Z (2 months ago)
- Topics: national-identification-number, personnummer, personnummervalidering, sweden
- Language: TypeScript
- Size: 1.04 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.com/MartinAskestad/sweden-national-id.svg?branch=master)](https://travis-ci.com/MartinAskestad/sweden-national-id)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)# sweden-national-id
Validation and parsing of the Swedish national identification number as well as co-ordination numbers for foreign citizens.
Install with npm
`npm i sweden-national-id`
## Examples
### JavaScript
```js
var swedenNationalId = require("sweden-national-id");// National id number
swedenNationalId.parse("850823-6463"); // { dateOfBirth: 1985-08-23T00:00:00.000Z, gender: 0, nationalIdNumber: '850823-6463', isFutureDate: false, isUnder18: false }// Co-ordination number
swedenNationalId.parse("850863-6464"); // { dateOfBirth: 1985-08-23T00:00:00.000Z, gender: 0, nationalIdNumber: '850823-6460', isFutureDate: false, isUnder18: false }// Corporate id number
swedenNationalId.parse("556036-0793"); // { nationalIdNumber: "556036-0793", numberType: 5 }// Invalid number
swedenNationalId.parse("850823-6464"); // null
```[Test on runkit](https://runkit.com/martinaskestad/sweden-national-id)
### TypeScript
```ts
const { parse } from 'sweden-national-id';// National id number
parse('850823-6463'); // { dateOfBirth: 1985-08-23T00:00:00.000Z, gender: 0, nationalIdNumber: '850823-6463', isFutureDate: false, isUnder18: false }// Co-ordination number
parse('850863-6464'); // { dateOfBirth: 1985-08-23T00:00:00.000Z, gender: 0, nationalIdNumber: '850863-6460', isFutureDate: false, isUnder18: false }// Person over 100 years
parse('850863+6464'); // { dateOfBirth: 1885-08-23T00:00:00.000Z, gender: 0, nationalIdNumber: '850823+6460', isFutureDate: false, isUnder18: false }// 12-digit format of id number
parse('198508636460'); // { dateOfBirth: 1985-08-23T00:00:00.000Z, gender: 0, nationalIdNumber: '850823-6460', isFutureDate: false, isUnder18: false }// Corporate id number
parse('556036-0793'); // { nationalIdNumber: "556036-0793", numberType: 5 }// Invalid number
parse('850823-6464'); // null
```