Skip to content

Commit

Permalink
Add Dutch identity card check
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinvanderVliet authored Nov 12, 2023
1 parent b958bd7 commit f80e519
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/lib/isIdentityCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,23 @@ const validators = {
if (str === 'CA00000AA') return false; // https://it.wikipedia.org/wiki/Carta_d%27identit%C3%A0_elettronica_italiana
return str.search(/C[A-Z]\d{5}[A-Z]{2}/is) > -1;
},
NL: (str) => {
if (!/^\d{8,9}$/.test(str)) return false;

str = `0${str}`.slice(-9);

let sum = 0;

for (let i = 0; i < 9; i++) {
if (i === 8) {
sum += str[i] * -1;
} else {
sum += str[i] * (9 - i);
}
}

return !(sum % 11);
},
NO: (str) => {
const sanitized = str.trim();
if (isNaN(Number(sanitized))) return false;
Expand Down

0 comments on commit f80e519

Please sign in to comment.