@estkit/personal-code
v0.0.7
Published
Parse Estonian Personal Identification Numbers
Downloads
851
Maintainers
Readme
@estkit/personal-code
A Javascript library to work with Estonian Personal Codes (isikukood).
Read about what's stored in the personal code here.
Features
- Encoding/decoding + validation
- Placeholders(39x1x...)
- Randomizing
Usage
Install from npm
npm install @estkit/personal-code
ESM usage (recommended):
import { encode, decode, randomize } from "@estkit/personal-code";
const { results, errors } = decode("39112120752");
CJS usage:
const { encode, decode, randomize } = require("@estkit/personal-code");
const { results, errors } = decode("39112120752");
Browser script usage:
<script src="personalcode.js"></script>
<script>
const { encode, decode, randomize } = EstonianPersonalCode;
const { results, errors } = decode("39112120752");
</script>
Standard compliance
This library complies with EVS 585:2007 except for one case.
According to the standard, the first number of the personal code has to be between 1-6, but this library supports 1-8.
To comply with the standard, you should check that year.max and year.actual are smaller than 2100.