Comparing version 1.0.2 to 1.0.3
@@ -5,6 +5,6 @@ (function () { | ||
kennitala.isValidCompany = function(){ | ||
kennitala.isValidPerson = function(kennitala){ | ||
var kt = formatKennitala(kennitala); | ||
if (!isCompany(kt)) { | ||
if (!isPerson(kt)) { | ||
return false; | ||
@@ -22,8 +22,8 @@ }; | ||
return (remainder == 11 && secretNr == 0) || remainder == secretNr; | ||
} | ||
}; | ||
kennitala.isValidPerson = function(kennitala){ | ||
kennitala.isValidCompany = function(kennitala){ | ||
var kt = formatKennitala(kennitala); | ||
if (!isPerson(kt)) { | ||
if (!isCompany(kt)) { | ||
return false; | ||
@@ -41,4 +41,9 @@ }; | ||
return (remainder == 11 && secretNr == 0) || remainder == secretNr; | ||
} | ||
}; | ||
kennitala.clean = function(kennitala){ | ||
return formatKennitala(kennitala); | ||
}; | ||
// People have first two characters between 1-31 | ||
function isPerson(kt){ | ||
@@ -50,2 +55,3 @@ var d = kt.substr(0, 2); | ||
// Companies have first two characters between 41-71 | ||
function isCompany(kt){ | ||
@@ -57,7 +63,6 @@ var d = kt.substr(0, 2); | ||
// Ensures datatype is string, then removes all non-digit characters from kennitala | ||
function formatKennitala(p_kennitala){ | ||
// Make sure kennitala is string | ||
var kennitala = ""+p_kennitala; | ||
// Remove unwanted characters from kennitala | ||
kennitala = kennitala.replace(/[^0-9]/, ''); | ||
@@ -68,3 +73,3 @@ | ||
// AMD/CommonJS/PlainJS wrapper | ||
// UMD wrapper | ||
if(typeof module !== 'undefined' && module.exports) { | ||
@@ -71,0 +76,0 @@ module.exports = kennitala; |
{ | ||
"name": "kennitala", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A validator module to check the checksum of Icelandic kennitölur", | ||
@@ -11,3 +11,6 @@ "main": "kennitala.js", | ||
"url" : "https://github.com/HermannBjorgvin/Kennitala.git" | ||
}, | ||
"scripts": { | ||
"test": "node test/test.js" | ||
} | ||
} |
@@ -11,1 +11,7 @@ # Kennitala | ||
Based off of old code, so defintiely not bullet proof, if you have a pull request it will almost definitely get accepted. | ||
### Things to add: | ||
Kennitala generator, for both people and companies | ||
Unit tests for everything |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4403
6
57
17