Comparing version 0.0.3 to 0.0.4
33
index.js
@@ -212,3 +212,3 @@ var sprintf = require('sprintf').sprintf; | ||
exports.generate = function generate(state) { | ||
exports.generate = function (state) { | ||
state = state || states[Math.floor(Math.random() * (states.length - 1))]; | ||
@@ -230,1 +230,32 @@ state = state.toUpperCase().trim();; | ||
exports.validate = function (ssn) { | ||
ssn = ssn.replace(/-/g,''); | ||
if( ssn.length !== 9 ) { | ||
console.log('invalid length'); | ||
return false; | ||
} | ||
if( isNaN(ssn) ) { | ||
console.log('not a number'); | ||
return false; | ||
} | ||
var area_number = ssn.substr(0, 3); | ||
var group_number = ssn.substr(3,2); | ||
var last_four = ssn.substr(5); | ||
area_number = Number(area_number); | ||
group_number = Number(group_number); | ||
last_four = Number(last_four); | ||
for( var state in statePrefixes ) { | ||
if ( statePrefixes[state].indexOf(area_number) !== -1 ) { | ||
if ( possibleGroups.indexOf(highgroup[area_number]) >= possibleGroups.indexOf(group_number) ) { | ||
return state; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
return false; | ||
} |
{ | ||
"name": "ssn", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Validate and generate fake SSN", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
14795
247