Skip to content

Instantly share code, notes, and snippets.

@reaktivo
Created March 29, 2018 15:34
Show Gist options
  • Save reaktivo/776628a8a5e30030f7a02fe1bd7a9e69 to your computer and use it in GitHub Desktop.
Save reaktivo/776628a8a5e30030f7a02fe1bd7a9e69 to your computer and use it in GitHub Desktop.
BSN Netherlands validation
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