Skip to content

Instantly share code, notes, and snippets.

@rarous
Last active December 6, 2021 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rarous/4e8451c8e4b4319edf399d8fce995afe to your computer and use it in GitHub Desktop.
Save rarous/4e8451c8e4b4319edf399d8fce995afe to your computer and use it in GitHub Desktop.
Validace IČ
export function registrationNumberValidator(regNr) {
if (!regNr || (typeof regNr !== "string") || regNr.length !== 8) return false;
const [n8, n7, n6, n5, n4, n3, n2, x] = regNr.split("").map(Number);
return (
x ===
(11 -
((8 * n8 + 7 * n7 + 6 * n6 + 5 * n5 + 4 * n4 + 3 * n3 + 2 * n2) % 11)) %
10
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment