indycheck 0.2.1 → 0.2.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/index.d.ts +10 -0
- package/dist/index.js +34 -0
- package/package.json +5 -1
package/dist/index.d.ts
CHANGED
|
@@ -255,6 +255,14 @@ export declare function generateGstin(stateCode?: unknown): string;
|
|
|
255
255
|
/** Generates a syntactically valid Indian mobile number (10 digits,
|
|
256
256
|
* first digit 6-9). TEST DATA ONLY — not a real person's number. */
|
|
257
257
|
export declare function generateMobile(): string;
|
|
258
|
+
/** Generates a syntactically valid state-format vehicle registration
|
|
259
|
+
* number (`DL01AB1234`: state code + district + series + number).
|
|
260
|
+
* TEST DATA ONLY — not a real issued registration number. */
|
|
261
|
+
export declare function generateVehicle(): string;
|
|
262
|
+
/** Generates a syntactically valid Bharat (BH) series vehicle number
|
|
263
|
+
* (`22BH1234AA`: year 21-26, `BH`, number 0001-9999, suffix without
|
|
264
|
+
* `I`/`O`). TEST DATA ONLY — not a real issued registration number. */
|
|
265
|
+
export declare function generateVehicleBharat(): string;
|
|
258
266
|
/** The Rust `detect` string for a trimmed input (lib.rs order). */
|
|
259
267
|
export declare function detectType(input: string): string;
|
|
260
268
|
export declare function detect(input: unknown): ValidationResult<DetectParsed>;
|
|
@@ -289,6 +297,8 @@ declare const _default: {
|
|
|
289
297
|
generateAadhaar: typeof generateAadhaar;
|
|
290
298
|
generateGstin: typeof generateGstin;
|
|
291
299
|
generateMobile: typeof generateMobile;
|
|
300
|
+
generateVehicle: typeof generateVehicle;
|
|
301
|
+
generateVehicleBharat: typeof generateVehicleBharat;
|
|
292
302
|
defaultOptions: typeof defaultOptions;
|
|
293
303
|
lenientOptions: typeof lenientOptions;
|
|
294
304
|
noSpacesHyphensOptions: typeof noSpacesHyphensOptions;
|
package/dist/index.js
CHANGED
|
@@ -109,6 +109,8 @@ exports.generatePan = generatePan;
|
|
|
109
109
|
exports.generateAadhaar = generateAadhaar;
|
|
110
110
|
exports.generateGstin = generateGstin;
|
|
111
111
|
exports.generateMobile = generateMobile;
|
|
112
|
+
exports.generateVehicle = generateVehicle;
|
|
113
|
+
exports.generateVehicleBharat = generateVehicleBharat;
|
|
112
114
|
exports.detectType = detectType;
|
|
113
115
|
exports.detect = detect;
|
|
114
116
|
exports.validateMany = validateMany;
|
|
@@ -986,6 +988,14 @@ function randomDigit() {
|
|
|
986
988
|
function randomDigitRange(low, high) {
|
|
987
989
|
return String(low + Math.floor(Math.random() * (high - low + 1)));
|
|
988
990
|
}
|
|
991
|
+
/** A letter excluding `I` and `O` (they look like digits on a plate). */
|
|
992
|
+
function randomLetterNoIO() {
|
|
993
|
+
const letters = "ABCDEFGHJKLMNPQRSTUVWXYZ";
|
|
994
|
+
return letters[Math.floor(Math.random() * letters.length)];
|
|
995
|
+
}
|
|
996
|
+
const VEHICLE_STATE_CODES = [
|
|
997
|
+
"DL", "MH", "UP", "KA", "TN", "GJ", "RJ", "WB", "KL", "PB", "HR", "AP", "TS", "MP", "BR",
|
|
998
|
+
];
|
|
989
999
|
/** Generates a syntactically valid PAN for the given entity character
|
|
990
1000
|
* (`P`, `C`, `H`, `F`, `A`, `T`, `B`, `L`, `J` or `G`).
|
|
991
1001
|
* An unknown entity character falls back to `P` (Individual).
|
|
@@ -1039,6 +1049,28 @@ function generateMobile() {
|
|
|
1039
1049
|
mobile += randomDigit();
|
|
1040
1050
|
return mobile;
|
|
1041
1051
|
}
|
|
1052
|
+
/** Generates a syntactically valid state-format vehicle registration
|
|
1053
|
+
* number (`DL01AB1234`: state code + district + series + number).
|
|
1054
|
+
* TEST DATA ONLY — not a real issued registration number. */
|
|
1055
|
+
function generateVehicle() {
|
|
1056
|
+
const state = VEHICLE_STATE_CODES[Math.floor(Math.random() * VEHICLE_STATE_CODES.length)];
|
|
1057
|
+
const district = String(1 + Math.floor(Math.random() * 99)).padStart(2, "0");
|
|
1058
|
+
const seriesLength = Math.random() < 0.5 ? 1 : 2;
|
|
1059
|
+
let series = "";
|
|
1060
|
+
for (let i = 0; i < seriesLength; i++)
|
|
1061
|
+
series += randomLetterNoIO();
|
|
1062
|
+
const number = String(1 + Math.floor(Math.random() * 9999)).padStart(4, "0");
|
|
1063
|
+
return `${state}${district}${series}${number}`;
|
|
1064
|
+
}
|
|
1065
|
+
/** Generates a syntactically valid Bharat (BH) series vehicle number
|
|
1066
|
+
* (`22BH1234AA`: year 21-26, `BH`, number 0001-9999, suffix without
|
|
1067
|
+
* `I`/`O`). TEST DATA ONLY — not a real issued registration number. */
|
|
1068
|
+
function generateVehicleBharat() {
|
|
1069
|
+
const year = String(21 + Math.floor(Math.random() * 6)).padStart(2, "0");
|
|
1070
|
+
const number = String(1 + Math.floor(Math.random() * 9999)).padStart(4, "0");
|
|
1071
|
+
const suffix = randomLetterNoIO() + randomLetterNoIO();
|
|
1072
|
+
return `${year}BH${number}${suffix}`;
|
|
1073
|
+
}
|
|
1042
1074
|
const VALIDATORS = {
|
|
1043
1075
|
mobile: validateMobile,
|
|
1044
1076
|
pan: validatePan,
|
|
@@ -1299,6 +1331,8 @@ exports.default = {
|
|
|
1299
1331
|
generateAadhaar,
|
|
1300
1332
|
generateGstin,
|
|
1301
1333
|
generateMobile,
|
|
1334
|
+
generateVehicle,
|
|
1335
|
+
generateVehicleBharat,
|
|
1302
1336
|
defaultOptions,
|
|
1303
1337
|
lenientOptions,
|
|
1304
1338
|
noSpacesHyphensOptions,
|
package/package.json
CHANGED
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
"optional": true
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/dusmamud/indycheck.git"
|
|
37
|
+
},
|
|
34
38
|
"scripts": {
|
|
35
39
|
"build": "tsc -p tsconfig.build.json",
|
|
36
40
|
"native:build": "npm --prefix ../../crates/indycheck-napi run build",
|
|
@@ -38,5 +42,5 @@
|
|
|
38
42
|
"typecheck": "tsc --noEmit"
|
|
39
43
|
},
|
|
40
44
|
"types": "dist/index.d.ts",
|
|
41
|
-
"version": "0.2.
|
|
45
|
+
"version": "0.2.2"
|
|
42
46
|
}
|