myanmar-nrc-validator 1.0.6 → 1.0.8
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/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +31 -0
- package/dist/cli.js.map +1 -0
- package/dist/types/nrc.d.ts +20 -0
- package/dist/types/nrc.d.ts.map +1 -0
- package/dist/types/nrc.js +2 -0
- package/dist/types/nrc.js.map +1 -0
- package/dist/utils/zod.d.ts +4 -0
- package/dist/utils/zod.d.ts.map +1 -0
- package/dist/utils/zod.js +13 -0
- package/dist/utils/zod.js.map +1 -0
- package/package.json +7 -1
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAqCA,OAAO,EAAE,CAAC"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { validateNRC } from "./utils/validator.js";
|
|
3
|
+
import { parseNRC } from "./utils/parser.js";
|
|
4
|
+
import { formatNRC } from "./utils/formatter.js";
|
|
5
|
+
const args = process.argv.slice(2);
|
|
6
|
+
const input = args[0];
|
|
7
|
+
if (!input || input === "--help" || input === "-h") {
|
|
8
|
+
console.log(`
|
|
9
|
+
Usage: npx myanmar-nrc-validator "<NRC_STRING>"
|
|
10
|
+
|
|
11
|
+
Example:
|
|
12
|
+
npx myanmar-nrc-validator "၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆"
|
|
13
|
+
`);
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
16
|
+
console.log(`\n🔍 Checking NRC: "${input}"\n`);
|
|
17
|
+
const isValid = validateNRC(input);
|
|
18
|
+
if (!isValid) {
|
|
19
|
+
console.error("❌ Result: Invalid Myanmar NRC format!");
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
console.log("✅ Result: Valid Myanmar NRC!");
|
|
23
|
+
const parsed = parseNRC(input);
|
|
24
|
+
if (parsed) {
|
|
25
|
+
console.log("\n📋 Parsed Details:");
|
|
26
|
+
console.log(JSON.stringify(parsed, null, 2));
|
|
27
|
+
console.log("\n🔄 Formats:");
|
|
28
|
+
console.log(`- English Format: ${formatNRC(input, "en")}`);
|
|
29
|
+
console.log(`- Myanmar Format: ${formatNRC(input, "mm")}`);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAEtB,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC;;;;;GAKX,CAAC,CAAC;IACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,OAAO,CAAC,GAAG,CAAC,uBAAuB,KAAK,KAAK,CAAC,CAAC;AAE/C,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;AACnC,IAAI,CAAC,OAAO,EAAE,CAAC;IACb,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC/B,IAAI,MAAM,EAAE,CAAC;IACX,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAE7C,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC7B,OAAO,CAAC,GAAG,CAAC,qBAAqB,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,qBAAqB,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type StateCode = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13" | "14" | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14;
|
|
2
|
+
export type CitizenTypeCode = "N" | "P" | "A" | "T";
|
|
3
|
+
export type CitizenTypeMm = "နိုင်" | "ပြု" | "ဧည့်" | "ယာယီ";
|
|
4
|
+
export type CitizenType = CitizenTypeCode | CitizenTypeMm;
|
|
5
|
+
export interface ParsedNRC {
|
|
6
|
+
stateCode: string;
|
|
7
|
+
stateNameEn: string;
|
|
8
|
+
stateNameMm: string;
|
|
9
|
+
township: string;
|
|
10
|
+
type: CitizenType;
|
|
11
|
+
number: string;
|
|
12
|
+
raw: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ComposeOptions {
|
|
15
|
+
stateCode: StateCode;
|
|
16
|
+
township: string;
|
|
17
|
+
type: CitizenType;
|
|
18
|
+
number: string | number;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=nrc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nrc.d.ts","sourceRoot":"","sources":["../../src/types/nrc.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,CAAC;AAEP,MAAM,MAAM,eAAe,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AACpD,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAC9D,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG,aAAa,CAAC;AAE1D,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nrc.js","sourceRoot":"","sources":["../../src/types/nrc.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/utils/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,eAAe,aAE1B,CAAC;AAEH,wBAAgB,gBAAgB,SAM/B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { validateNRC } from "./validator.js";
|
|
3
|
+
export const nrcStringSchema = z.string().refine((val) => validateNRC(val), {
|
|
4
|
+
message: "Invalid Myanmar National Registration Certificate (NRC) format",
|
|
5
|
+
});
|
|
6
|
+
export function extendZodWithNRC() {
|
|
7
|
+
z.ZodString.prototype.nrc = function (message) {
|
|
8
|
+
return this.refine((val) => validateNRC(val), {
|
|
9
|
+
message: message || "Invalid Myanmar NRC format",
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=zod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod.js","sourceRoot":"","sources":["../../src/utils/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;IAC1E,OAAO,EAAE,gEAAgE;CAC1E,CAAC,CAAC;AAEH,MAAM,UAAU,gBAAgB;IAC7B,CAAS,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,GAAG,UAAU,OAAgB;QAC7D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;YACpD,OAAO,EAAE,OAAO,IAAI,4BAA4B;SACjD,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "myanmar-nrc-validator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "A simple npm package to validate Myanmar NRC numbers",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
|
+
"bin": {
|
|
17
|
+
"myanmar-nrc-validator": "./dist/cli.js"
|
|
18
|
+
},
|
|
16
19
|
"scripts": {
|
|
17
20
|
"build": "tsc",
|
|
18
21
|
"prepublishOnly": "npm run build",
|
|
@@ -30,5 +33,8 @@
|
|
|
30
33
|
"@types/node": "^26.6.4",
|
|
31
34
|
"rimraf": "^6.1.3",
|
|
32
35
|
"typescript": "^7.0.2"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"zod": "^4.6.5"
|
|
33
39
|
}
|
|
34
40
|
}
|