Created
October 9, 2016 16:57
-
-
Save karna41317/d3ce512be287102bd56bcb11f05b8b01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function isValidPersonalNumber (personalNumber) { | |
let matches = personalNumber | |
.match(/^(19|20)((\d{2})(\d{2})(\d{2})-{0,1}\d{4})$/); | |
if (matches) { | |
let year = parseInt(matches[1] + matches[3], 10); | |
return !!(year < CURRENT_YEAR && isValidSwedishPIN(matches[2])); | |
} else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment