3.1.4 • Published 2 months ago

isikukood v3.1.4

Weekly downloads
242
License
MIT
Repository
github
Last release
2 months ago

Estonian personal ID (isikukood)

License MIT Build Version

JavaScript class for both browser and Node. Generates and validates Estonian personal IDs.

Check demo

Version 3

  • Fully backwards compatible with previous major versions 2.x.x and 1.x.x.
  • Migrated to TypeScript.
  • Removed CommonJS support, use ESModules.

Version 2

  • Fully backwards compatible with previous major versions 1.x.x.

Install

Install via npm, yarn or pnpm.

npm install isikukood
yarn install isikukood
pnpm install isikukood

Download and include JS file into your HTML.

<script src="./dist/isikukood.esm.js" type="module"></script>

Using ES Modules

import {Isikukood} from './dist/isikukood.esm.js';

Usage

Usage example.

// Validation
const ik = new Isikukood('47502124911');
const isValid = ik.validate(); // true is valid, false isn't valid
const sex = ik.getGender(); // "male" or "female"
const age = ik.getAge(); // person's age
const birthday = ik.getBirthday(); // person's birthday

// Generation
const validIk = Isikukood.generate(); // "49002124277"

// Generate with parameters
const maleIk = Isikukood.generate({
  gender: 'male',
  birthDay: 23,
  birthMonth: 3,
  birthYear: 1984,
});

API

Instance methods

MethodDescriptionArgumentsReturn
new Isikukood()constructornumber | stringIsikukood
validate()Validates personal ID-boolean
generate()Static function generates a valid personal IDGenerateInputstring
getGender()Get the gender of a person-Gender
getBirthday()Get the birthday of a person-Date
getAge()Get the birthday of a person in years-number
getControlNumber()Gets the control number of personal ID-number
parse()Parses the code-PersonalData

Static methods

MethodDescriptionArgumentsReturn
parse()Parses the codenumber | stringPersonalData

Development

Be sure that your GNU Make software is installed on your system. Development commands are very simple.

Everything

make

Build

make build

Test

make test

Contribution

Any help is appreciated. Found a bug, typo, inaccuracy, etc.? Please do not hesitate to make a pull request or file an issue.

License

MIT License 2014-2023

3.1.4

2 months ago

3.1.3

2 months ago

3.1.2

5 months ago

3.1.1

7 months ago

3.1.0

12 months ago

3.0.1

12 months ago

3.0.0

12 months ago

2.0.1

2 years ago

2.0.0

2 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.1.5

6 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

9 years ago