@accounter/shaam6111-generator
Version:
Fully typed application that generates, parses, and validates SHAAM 6111 tax reports.
19 lines (18 loc) • 610 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isValidIsraeliID = isValidIsraeliID;
function isValidIsraeliID(rawId) {
let id = String(rawId).trim();
if (id.length > 9 || id.length < 5)
return false;
if (!/^\d+$/.test(id))
return false;
// Pad string with zeros up to 9 digits
id = id.length < 9 ? ('00000000' + id).slice(-9) : id;
return (Array.from(id, Number).reduce((counter, digit, i) => {
const step = digit * ((i % 2) + 1);
return counter + (step > 9 ? step - 9 : step);
}) %
10 ===
0);
}