Coder Social home page Coder Social logo

isikukood-js's Introduction

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

Method Description Arguments Return
new Isikukood() constructor number | string Isikukood
validate() Validates personal ID - boolean
generate() Static function generates a valid personal ID GenerateInput string
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

Method Description Arguments Return
parse() Parses the code number | string PersonalData

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

isikukood-js's People

Contributors

dknight avatar dependabot[bot] avatar vellotis avatar randohinn avatar jaakritso avatar xpaw avatar trangoul avatar aleksei123 avatar

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.