myanmar-nrc-validator 1.0.8 → 1.0.12

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.
Files changed (2) hide show
  1. package/README.md +122 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,122 @@
1
+
2
+ ---
3
+
4
+ # myanmar-nrc-validator 🇲🇲
5
+
6
+ A lightweight, robust, and zero-dependency (except Zod) TypeScript/JavaScript library for validating, parsing, and formatting Myanmar National Registration Card (NRC) numbers. Supports both English and Myanmar text formats, along with a handy CLI tool.
7
+
8
+ ---
9
+
10
+ ## Features ✨
11
+
12
+ * **Validation**: Accurately validates Myanmar NRC numbers (format, state codes, township codes, citizen types, and number lengths).
13
+ * **Parsing**: Extracts structured data (State, Township, Citizen Type, and Numbers) from NRC strings.
14
+ * **Formatting**: Converts NRC strings smoothly between Myanmar and English formats.
15
+ * **Zod Integration**: Provides built-in Zod schemas for form validation (e.g., in Express, NestJS, or React forms).
16
+ * **CLI Support**: Quickly check NRC numbers straight from your terminal via `npx myanmar-nrc-validator`.
17
+
18
+ ---
19
+
20
+ ## Installation 📦
21
+
22
+ Install the package via npm:
23
+
24
+ ```bash
25
+ npm install myanmar-nrc-validator
26
+
27
+ ```
28
+
29
+ ---
30
+
31
+ ## CLI Usage 💻
32
+
33
+ You can test or validate NRC numbers directly from your terminal using `npx`:
34
+
35
+ ```bash
36
+ npx myanmar-nrc-validator "12/UKAMA(N)123456"
37
+
38
+ ```
39
+
40
+
41
+ ```bash
42
+ npx myanmar-nrc-validator "၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆"
43
+
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Programmatic Usage (JavaScript / TypeScript) 🚀
49
+
50
+ ### 1. Validate NRC (`validateNRC`)
51
+
52
+ Checks whether a given NRC string is valid or not.
53
+
54
+ ```typescript
55
+ import { validateNRC } from "myanmar-nrc-validator";
56
+
57
+ console.log(validateNRC("၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆")); // true
58
+ console.log(validateNRC("12/UKAMA(N)123456")); // true
59
+ console.log(validateNRC("99/XYZ(N)123456")); // false (Invalid state/township)
60
+
61
+ ```
62
+
63
+ ### 2. Parse NRC (`parseNRC`)
64
+
65
+ Extracts detailed information from an NRC string.
66
+
67
+ ```typescript
68
+ import { parseNRC } from "myanmar-nrc-validator";
69
+
70
+ const result = parseNRC("၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆");
71
+ console.log(result);
72
+ /*
73
+ Output:
74
+ {
75
+ stateNumber: "12",
76
+ townshipCode: "ဥကမ",
77
+ citizenType: "နိုင်",
78
+ number: "၁၂၃၄၅၆"
79
+ }
80
+ */
81
+
82
+ ```
83
+
84
+ ### 3. Format NRC (`formatNRC`)
85
+
86
+ Converts NRC text between Myanmar script and English format (`en` / `mm`).
87
+
88
+ ```typescript
89
+ import { formatNRC } from "myanmar-nrc-validator";
90
+
91
+ // Convert to English format
92
+ console.log(formatNRC("၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆", "en"));
93
+ // Output: 12/UKAMA(N)123456
94
+
95
+ // Convert to Myanmar format
96
+ console.log(formatNRC("12/UKAMA(N)123456", "mm"));
97
+ // Output: ၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆
98
+
99
+ ```
100
+
101
+ ### 4. Zod Schema Validation (`nrcStringSchema`)
102
+
103
+ Useful for API validation (e.g., with Zod, NestJS, Express, or React Hook Form).
104
+
105
+ ```typescript
106
+ import { nrcStringSchema } from "myanmar-nrc-validator";
107
+
108
+ const validationResult = nrcStringSchema.safeParse("၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆");
109
+
110
+ if (validationResult.success) {
111
+ console.log("Valid NRC!");
112
+ } else {
113
+ console.log("Validation failed:", validationResult.error.format());
114
+ }
115
+
116
+ ```
117
+
118
+ ---
119
+
120
+ ## License 📄
121
+
122
+ [MIT](https://www.google.com/search?q=LICENSE) © Aung Phyo Khant
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myanmar-nrc-validator",
3
- "version": "1.0.8",
3
+ "version": "1.0.12",
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",
@@ -14,7 +14,8 @@
14
14
  "dist"
15
15
  ],
16
16
  "bin": {
17
- "myanmar-nrc-validator": "./dist/cli.js"
17
+ "myanmar-nrc-validator": "./dist/cli.js",
18
+ "nrc": "./dist/cli.js"
18
19
  },
19
20
  "scripts": {
20
21
  "build": "tsc",