@alwatr/iranian-national-code-validator 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +2 -2
- package/dist/main.js.map +1 -1
- package/package.json +4 -4
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 📦 @alwatr/iranian-national-code-validator v2.0.
|
|
1
|
+
/* 📦 @alwatr/iranian-national-code-validator v2.0.2 */
|
|
2
2
|
function n(i){if(!/^\d{10}$/.test(i))return!1;let a=+i[9],e=i.split("").slice(0,9).reduce((t,o,l)=>t+ +o*(10-l),0)%11;return e<2?a===e:a+e===11}export{n as isValidIranianNationalCode};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=9A94D8D58B5CC13364756E2164756E21
|
|
5
5
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"/**\n * Validates an Iranian National Code (Code Melli).\n *\n * The validation is based on the official algorithm:\n * 1. The code must be 10 digits.\n * 2. The last digit is a check digit.\n * 3. A weighted sum of the first 9 digits is calculated.\n * 4. The remainder of the sum divided by 11 is compared with the check digit based on a specific rule.\n *\n * @param str The Iranian National Code to validate.\n * @returns `true` if the national code is valid, `false` otherwise.\n *\n * @example\n * ```ts\n * console.log(isValidIranianNationalCode('0018550152')); // true\n * console.log(isValidIranianNationalCode('0018550153')); // false\n * console.log(isValidIranianNationalCode('12345')); // false\n * ```\n */\nexport function isValidIranianNationalCode(str: string): boolean {\n if (!/^\\d{10}$/.test(str)) return false;\n\n const check = +str[9];\n const sum = str.split('').slice(0, 9).reduce((acc, x, i) => acc + +x * (10 - i), 0) % 11;\n\n return sum < 2 ? check === sum : check + sum === 11;\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";AAmBO,SAAS,CAA0B,CAAC,EAAsB,CAC/D,GAAI,CAAC,WAAW,KAAK,CAAG,EAAG,MAAO,GAElC,IAAM,EAAQ,CAAC,EAAI,GACb,EAAM,EAAI,MAAM,EAAE,EAAE,MAAM,EAAG,CAAC,EAAE,OAAO,CAAC,EAAK,EAAG,IAAM,GAAM,CAAC,GAAK,GAAK,GAAI,CAAC,EAAI,GAEtF,OAAO,EAAM,EAAI,IAAU,EAAM,EAAQ,IAAQ",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "9A94D8D58B5CC13364756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/iranian-national-code-validator",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "A tiny TypeScript library to Validates an Iranian National Code (Code Melli).",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"@alwatr/nano-build": "7.0.1",
|
|
24
24
|
"@alwatr/prettier-config": "7.0.1",
|
|
25
25
|
"@alwatr/tsconfig-base": "8.0.0",
|
|
26
|
-
"@alwatr/type-helper": "8.0.
|
|
27
|
-
"typescript": "^
|
|
26
|
+
"@alwatr/type-helper": "8.0.2",
|
|
27
|
+
"typescript": "^6.0.2"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"b": "bun run build",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"validator"
|
|
71
71
|
],
|
|
72
72
|
"prettier": "@alwatr/prettier-config",
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "95bb13efd0a5f485c6b09f1a911b99492017aed1"
|
|
74
74
|
}
|