ind-utils-pro 1.0.0

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/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # 🇮🇳 Ind-Utils-Pro
2
+ A professional, lightweight, and framework-agnostic Indian utility library for Angular, React, Vue, and Node.js.
3
+
4
+ ## 🚀 Features
5
+ - **Identity:** PAN, GST, Aadhar, VoterID, Passport, Driving License.
6
+ - **Finance:** IFSC, Account Number, TAN, DIN, CIN, Currency to Words.
7
+ - **Location:** Pincode, Mobile, Vehicle Registration.
8
+ - **Formatting:** Indian Rupee (INR) formatting.
9
+
10
+ ## 📦 Installation
11
+ ```bash
12
+ npm install ind-utils-pro
13
+
14
+
15
+ # ================= In React / Vue / Vanilla JS =================
16
+ # import { IndUtils } from 'ind-utils-pro';
17
+
18
+ # const isPanValid = IndUtils.isValidPAN('ABCDE1234F'); // true
19
+ # const amountInWords = IndUtils.toIndianWords(5000); // Five Thousand Rupees Only
20
+
21
+
22
+ # ================= In Angular =================
23
+ # import { IndUtils } from 'ind-utils-pro';
24
+
25
+ # export class AppComponent {
26
+ # checkGst() {
27
+ # const isValid = IndUtils.isValidGST('24AAAAA0000A1Z5');
28
+ # console.log(isValid);
29
+ # }
30
+ # }
31
+
32
+
33
+ # ================= In Node.js =================
34
+ # const { IndUtils } = require('ind-utils-pro');
35
+ # console.log(IndUtils.isValidPincode('380001'));
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "ind-utils-pro",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "Universal Indian Utility Library",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "scripts": {
10
+ "build": "tsup src/index.ts --format cjs,esm --clean --minify && tsc --emitDeclarationOnly",
11
+ "dev": "tsup src/index.ts --format cjs,esm --watch --dts"
12
+ },
13
+ "devDependencies": {
14
+ "@microsoft/api-extractor": "^7.57.7",
15
+ "tsup": "^8.0.0",
16
+ "typescript": "^5.0.0"
17
+ }
18
+ }
@@ -0,0 +1,23 @@
1
+ export const REGEX = {
2
+ // Identity
3
+ PAN: /^[A-Z]{5}[0-9]{4}[A-Z]{1}$/,
4
+ GST: /^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/,
5
+ AADHAR: /^[2-9]{1}[0-9]{11}$/,
6
+ VOTER_ID: /^[A-Z]{3}[0-9]{7}$/,
7
+ PASSPORT: /^[A-Z][0-9]{7}$/,
8
+ DRIVING_LICENSE: /^(([A-Z]{2}[0-9]{2})( )|([A-Z]{2}-[0-9]{2}))((19|20)[0-9][0-9])[0-9]{7}$/,
9
+
10
+ // Finance & Business
11
+ IFSC: /^[A-Z]{4}0[A-Z0-9]{6}$/,
12
+ TAN: /^[A-Z]{4}[0-9]{5}[A-Z]{1}$/,
13
+ DIN: /^[0-9]{8}$/,
14
+ CIN: /^([LUu])([0-9]{5})([A-Z]{2})([0-9]{4})([A-Z]{3})([0-9]{6})$/,
15
+
16
+ // Contact & Location
17
+ PINCODE: /^[1-9][0-9]{5}$/,
18
+ MOBILE: /^[6-9]\d{9}$/,
19
+ STD_CODE: /^0[0-9]{2,4}$/,
20
+
21
+ // Vehicles (General Format)
22
+ VEHICLE_NO: /^[A-Z]{2}[0-9]{2}[A-Z]{1,2}[0-9]{4}$/
23
+ };
@@ -0,0 +1,28 @@
1
+ export const toINR = (amount: number): string => {
2
+ if (isNaN(amount)) return '₹0.00';
3
+ return new Intl.NumberFormat('en-IN', {
4
+ style: 'currency',
5
+ currency: 'INR',
6
+ }).format(amount);
7
+ };
8
+
9
+ export const toIndianWords = (num: number): string => {
10
+ const a = ['', 'One ', 'Two ', 'Three ', 'Four ', 'Five ', 'Six ', 'Seven ', 'Eight ', 'Nine ', 'Ten ', 'Eleven ', 'Twelve ', 'Thirteen ', 'Fourteen ', 'Fifteen ', 'Sixteen ', 'Seventeen ', 'Eighteen ', 'Nineteen '];
11
+ const b = ['', '', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'];
12
+
13
+ // સંખ્યાને સ્ટ્રિંગમાં કન્વર્ટ કરવા માટે નવો વેરીએબલ વાપરો (Error Fix)
14
+ const numStr = num.toString();
15
+ if (numStr.length > 9) return 'Overflow';
16
+
17
+ const n = ('000000000' + numStr).substr(-9).match(/^(\d{2})(\d{2})(\d{2})(\d{1})(\d{2})$/);
18
+ if (!n) return '';
19
+
20
+ let str = '';
21
+ str += (Number(n[1]) !== 0) ? (a[Number(n[1])] || b[parseInt(n[1][0])] + ' ' + a[parseInt(n[1][1])]) + 'Crore ' : '';
22
+ str += (Number(n[2]) !== 0) ? (a[Number(n[2])] || b[parseInt(n[2][0])] + ' ' + a[parseInt(n[2][1])]) + 'Lakh ' : '';
23
+ str += (Number(n[3]) !== 0) ? (a[Number(n[3])] || b[parseInt(n[3][0])] + ' ' + a[parseInt(n[3][1])]) + 'Thousand ' : '';
24
+ str += (Number(n[4]) !== 0) ? (a[Number(n[4])] || b[parseInt(n[4][0])] + ' ' + a[parseInt(n[4][1])]) + 'Hundred ' : '';
25
+ str += (Number(n[5]) !== 0) ? ((str !== '') ? 'and ' : '') + (a[Number(n[5])] || b[parseInt(n[5][0])] + ' ' + a[parseInt(n[5][1])]) + 'Rupees Only' : '';
26
+
27
+ return str.trim();
28
+ };
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ export * from './validators/identity';
2
+ export * from './constants/patterns';
3
+ export * from './formatters/currency';
4
+
5
+ import * as identity from './validators/identity';
6
+ import * as currency from './formatters/currency';
7
+
8
+ export const IndUtils = {
9
+ ...identity,
10
+ ...currency
11
+ };
@@ -0,0 +1,23 @@
1
+ import { REGEX } from '../constants/patterns';
2
+
3
+ // --- Government IDs ---
4
+ export const isValidPAN = (v: string) => REGEX.PAN.test(v?.toUpperCase());
5
+ export const isValidGST = (v: string) => REGEX.GST.test(v?.toUpperCase());
6
+ export const isValidAadhar = (v: string) => REGEX.AADHAR.test(v);
7
+ export const isValidVoterID = (v: string) => REGEX.VOTER_ID.test(v?.toUpperCase());
8
+ export const isValidPassport = (v: string) => REGEX.PASSPORT.test(v?.toUpperCase());
9
+ export const isValidDrivingLicense = (v: string) => REGEX.DRIVING_LICENSE.test(v?.toUpperCase());
10
+
11
+ // --- Business & Finance ---
12
+ export const isValidIFSC = (v: string) => REGEX.IFSC.test(v?.toUpperCase());
13
+ export const isValidTAN = (v: string) => REGEX.TAN.test(v?.toUpperCase());
14
+ export const isValidDIN = (v: string) => REGEX.DIN.test(v);
15
+ export const isValidCIN = (v: string) => REGEX.CIN.test(v?.toUpperCase());
16
+
17
+ // --- Contact ---
18
+ export const isValidPincode = (v: string) => REGEX.PINCODE.test(v);
19
+ export const isValidMobile = (v: string) => REGEX.MOBILE.test(v);
20
+ export const isValidVehicleNo = (v: string) => REGEX.VEHICLE_NO.test(v?.toUpperCase());
21
+
22
+ // --- Specialized Checks ---
23
+ export const isUPIDeposited = (v: string) => /^[a-zA-Z0-9.\-_]{2,256}@[a-zA-Z]{2,64}$/.test(v);
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "declaration": true,
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "outDir": "dist"
12
+ },
13
+ "include": ["src/**/*"],
14
+ "exclude": ["node_modules", "dist"]
15
+ }