Created
March 29, 2018 15:34
-
-
Save reaktivo/776628a8a5e30030f7a02fe1bd7a9e69 to your computer and use it in GitHub Desktop.
BSN Netherlands validation
This file contains hidden or 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 default const validateBsn = (bsn = '') => { | |
// Needs to be 9 characters | |
if (bsn.length !== 9) { | |
return false; | |
} | |
const VALUES = [9, 8, 7, 6, 5, 4, 3, 2, -1]; | |
const total = bsn | |
.split('') // make it an enumerable | |
.reduce((p, c, i) => Number(p) + c * VALUES[i], 0); | |
return total % 11 === 0; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment