@alwatr/iranian-national-code-validator 1.0.4 → 1.0.5
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/CHANGELOG.md +4 -0
- package/dist/main.cjs +2 -36
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs +2 -12
- package/dist/main.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.5](https://github.com/Alwatr/nanolib/compare/@alwatr/iranian-national-code-validator@1.0.4...@alwatr/iranian-national-code-validator@1.0.5) (2025-09-15)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @alwatr/iranian-national-code-validator
|
|
9
|
+
|
|
6
10
|
## [1.0.4](https://github.com/Alwatr/nanolib/compare/@alwatr/iranian-national-code-validator@1.0.3...@alwatr/iranian-national-code-validator@1.0.4) (2025-09-13)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @alwatr/iranian-national-code-validator
|
package/dist/main.cjs
CHANGED
|
@@ -1,37 +1,3 @@
|
|
|
1
|
-
/* @alwatr/iranian-national-code-validator v1.0.
|
|
2
|
-
"use strict";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/main.ts
|
|
22
|
-
var main_exports = {};
|
|
23
|
-
__export(main_exports, {
|
|
24
|
-
isValidIranianNationalCode: () => isValidIranianNationalCode
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(main_exports);
|
|
27
|
-
function isValidIranianNationalCode(str) {
|
|
28
|
-
if (!/^\d{10}$/.test(str)) return false;
|
|
29
|
-
const check = +str[9];
|
|
30
|
-
const sum = str.split("").slice(0, 9).reduce((acc, x, i) => acc + +x * (10 - i), 0) % 11;
|
|
31
|
-
return sum < 2 ? check === sum : check + sum === 11;
|
|
32
|
-
}
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
isValidIranianNationalCode
|
|
36
|
-
});
|
|
1
|
+
/* @alwatr/iranian-national-code-validator v1.0.5 */
|
|
2
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var main_exports={};__export(main_exports,{isValidIranianNationalCode:()=>isValidIranianNationalCode});module.exports=__toCommonJS(main_exports);function isValidIranianNationalCode(str){if(!/^\d{10}$/.test(str))return false;const check=+str[9];const sum=str.split("").slice(0,9).reduce((acc,x,i)=>acc+ +x*(10-i),0)%11;return sum<2?check===sum:check+sum===11}0&&(module.exports={isValidIranianNationalCode});
|
|
37
3
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.cjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
4
|
"sourcesContent": ["/**\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"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";qqBAAA,iJAmBO,SAAS,2BAA2B,IAAsB,CAC/D,GAAI,CAAC,WAAW,KAAK,GAAG,EAAG,MAAO,OAElC,MAAM,MAAQ,CAAC,IAAI,CAAC,EACpB,MAAM,IAAM,IAAI,MAAM,EAAE,EAAE,MAAM,EAAG,CAAC,EAAE,OAAO,CAAC,IAAK,EAAG,IAAM,KAAM,CAAC,GAAK,GAAK,GAAI,CAAC,EAAI,GAEtF,OAAO,IAAM,EAAI,QAAU,IAAM,MAAQ,MAAQ,EACnD",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/main.mjs
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/* @alwatr/iranian-national-code-validator v1.0.
|
|
2
|
-
|
|
3
|
-
// src/main.ts
|
|
4
|
-
function isValidIranianNationalCode(str) {
|
|
5
|
-
if (!/^\d{10}$/.test(str)) return false;
|
|
6
|
-
const check = +str[9];
|
|
7
|
-
const sum = str.split("").slice(0, 9).reduce((acc, x, i) => acc + +x * (10 - i), 0) % 11;
|
|
8
|
-
return sum < 2 ? check === sum : check + sum === 11;
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
isValidIranianNationalCode
|
|
12
|
-
};
|
|
1
|
+
/* @alwatr/iranian-national-code-validator v1.0.5 */
|
|
2
|
+
function isValidIranianNationalCode(str){if(!/^\d{10}$/.test(str))return false;const check=+str[9];const sum=str.split("").slice(0,9).reduce((acc,x,i)=>acc+ +x*(10-i),0)%11;return sum<2?check===sum:check+sum===11}export{isValidIranianNationalCode};
|
|
13
3
|
//# sourceMappingURL=main.mjs.map
|
package/dist/main.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
4
|
"sourcesContent": ["/**\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"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAmBO,SAAS,2BAA2B,IAAsB,CAC/D,GAAI,CAAC,WAAW,KAAK,GAAG,EAAG,MAAO,OAElC,MAAM,MAAQ,CAAC,IAAI,CAAC,EACpB,MAAM,IAAM,IAAI,MAAM,EAAE,EAAE,MAAM,EAAG,CAAC,EAAE,OAAO,CAAC,IAAK,EAAG,IAAM,KAAM,CAAC,GAAK,GAAK,GAAI,CAAC,EAAI,GAEtF,OAAO,IAAM,EAAI,QAAU,IAAM,MAAQ,MAAQ,EACnD",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/iranian-national-code-validator",
|
|
3
3
|
"description": "A tiny TypeScript library to Validates an Iranian National Code (Code Melli).",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
|
|
6
6
|
"bugs": "https://github.com/Alwatr/nanolib/issues",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"@alwatr/nano-build": "6.
|
|
8
|
+
"@alwatr/nano-build": "6.2.0",
|
|
9
9
|
"@alwatr/prettier-config": "5.0.3",
|
|
10
10
|
"@alwatr/tsconfig-base": "6.0.1",
|
|
11
11
|
"@alwatr/type-helper": "6.0.2",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
},
|
|
72
72
|
"type": "module",
|
|
73
73
|
"types": "./dist/main.d.ts",
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "e081773e1ba6bf1c62c07d7dc966b174fa7dd3ea"
|
|
75
75
|
}
|