2.0.0-beta.3 • Published 6 months ago

kennitala v2.0.0-beta.3

Weekly downloads
737
License
MIT
Repository
github
Last release
6 months ago

Kennitala

A validator and general utility for Icelandic kennitölur in Javascript

Build Status

Compatible with CommonJS, AMD modules, regular Javascript.

Pull requests welcome

####Installation with npm:

$ npm install kennitala

####Installation with bower:

$ bower install kennitala

Example of usage

    var kennitala = require('kennitala');
    
    kennitala.clean('310896DIRTYSSID2099'); // '3108962099'
    kennitala.clean(3108962099);            // '3108962099'
    
    kennitala.isPerson('3108962099');            // True
    kennitala.isPerson('310896-2099');           // True
    kennitala.isPerson(3108962099);              // True
    kennitala.isPerson('31^_^08!!96LOL20T_T99'); // True
    
    kennitala.isCompany('6010100890');  // True
    kennitala.isCompany('601010-0890'); // True
    kennitala.isCompany(6010100890);    // True

API

kennitala.clean([string, int]);
    returns string

    Ensures datatype is string, then matches and removes all non-digit characters.
    Does not ensure the remaining string is 10 characters or that the kennitala is valid

kennitala.isPerson([string, int]);
    returns boolean

    Checks if kennitala checksum is correct and if day of birth is between 1-31
    If passed a string with non-digit characters included it removes them before validating

kennitala.isCompany([string, int]);
    returns boolean

    Checks if kennitala checksum is correct and if day of birth is between 41-71
    If passed a string with non-digit characters included it removes them before validating

Testing

Uses Mocha for testing. In order to execute the tests, you need to run npm install -g mocha first. Once you've done that you can open up a command line and point it to the root directory of the project. From there you should be able to type either npm test or simply mocha to run the tests.

Building

To build the project, you can type npm run dist, which minifies the script and generates a source map, and places both in the dist/ folder.

Coming soonTM

Kennitala generator, for both people and companies
2.0.0-beta.3

6 months ago

2.0.0-beta.2

2 years ago

2.0.0-beta.1

2 years ago

2.0.0-beta.0

2 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

4 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.2.0

7 years ago

1.1.0

8 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago