persian-mock-data 0.0.0-stage → 0.1.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/dist/index.cjs ADDED
@@ -0,0 +1,606 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ FORBIDDEN_REPEATED_NATIONAL_IDS: () => FORBIDDEN_REPEATED_NATIONAL_IDS,
24
+ INVALID_SCENARIOS: () => INVALID_SCENARIOS,
25
+ LANDLINE_AREAS: () => LANDLINE_AREAS,
26
+ MOBILE_PREFIXES: () => MOBILE_PREFIXES,
27
+ PERSIAN_FIRST_NAMES: () => PERSIAN_FIRST_NAMES,
28
+ PERSIAN_LAST_NAMES: () => PERSIAN_LAST_NAMES,
29
+ VIOLATED_RULES: () => VIOLATED_RULES,
30
+ calculateNationalIdCheckDigit: () => calculateNationalIdCheckDigit,
31
+ createRandom: () => createRandom,
32
+ generateFirstName: () => generateFirstName,
33
+ generateFullName: () => generateFullName,
34
+ generateLandline: () => generateLandline,
35
+ generateLastName: () => generateLastName,
36
+ generateMobile: () => generateMobile,
37
+ generateNationalId: () => generateNationalId,
38
+ generatePostalCode: () => generatePostalCode,
39
+ persianMock: () => persianMock,
40
+ resolveRandom: () => resolveRandom,
41
+ validateLandline: () => validateLandline,
42
+ validateMobile: () => validateMobile,
43
+ validateNationalId: () => validateNationalId,
44
+ validatePersianName: () => validatePersianName,
45
+ validatePostalCode: () => validatePostalCode
46
+ });
47
+ module.exports = __toCommonJS(index_exports);
48
+
49
+ // src/core/random.ts
50
+ function hashSeed(seed) {
51
+ const text = String(seed);
52
+ let hash = 2166136261;
53
+ for (let index = 0; index < text.length; index += 1) {
54
+ hash ^= text.charCodeAt(index);
55
+ hash = Math.imul(hash, 16777619);
56
+ }
57
+ return hash >>> 0;
58
+ }
59
+ function createRandom(seed = Date.now()) {
60
+ let state = hashSeed(seed);
61
+ const float = () => {
62
+ state = state + 1831565813 >>> 0;
63
+ let value = state;
64
+ value = Math.imul(value ^ value >>> 15, value | 1);
65
+ value ^= value + Math.imul(value ^ value >>> 7, value | 61);
66
+ return ((value ^ value >>> 14) >>> 0) / 4294967296;
67
+ };
68
+ return {
69
+ float,
70
+ integer(min, max) {
71
+ if (!Number.isInteger(min) || !Number.isInteger(max) || max < min) {
72
+ throw new RangeError("integer() requires integer bounds with max >= min");
73
+ }
74
+ return Math.floor(float() * (max - min + 1)) + min;
75
+ },
76
+ pick(values) {
77
+ if (values.length === 0) {
78
+ throw new RangeError("pick() requires at least one value");
79
+ }
80
+ return values[Math.floor(float() * values.length)];
81
+ },
82
+ digits(length) {
83
+ if (!Number.isInteger(length) || length < 0) {
84
+ throw new RangeError("digits() requires a non-negative integer length");
85
+ }
86
+ return Array.from({ length }, () => Math.floor(float() * 10)).join("");
87
+ }
88
+ };
89
+ }
90
+ function resolveRandom(source) {
91
+ if (typeof source === "object" && source !== null) {
92
+ return source;
93
+ }
94
+ return createRandom(source);
95
+ }
96
+
97
+ // src/data/person.ts
98
+ var PERSIAN_FIRST_NAMES = [
99
+ "\u0622\u0631\u0645\u0627\u0646",
100
+ "\u0622\u0648\u0627",
101
+ "\u0627\u0645\u06CC\u0631",
102
+ "\u0628\u0647\u0627\u0631",
103
+ "\u067E\u0627\u0631\u0633\u0627",
104
+ "\u062A\u0631\u0627\u0646\u0647",
105
+ "\u0631\u0647\u0627",
106
+ "\u0633\u0627\u0645",
107
+ "\u0633\u0627\u0631\u0627",
108
+ "\u0633\u067E\u0647\u0631",
109
+ "\u06A9\u06CC\u0627\u0646\u0627",
110
+ "\u0645\u0627\u0646\u06CC",
111
+ "\u0645\u0631\u06CC\u0645",
112
+ "\u0646\u06CC\u0645\u0627",
113
+ "\u0647\u0633\u062A\u06CC"
114
+ ];
115
+ var PERSIAN_LAST_NAMES = [
116
+ "\u0627\u062D\u0645\u062F\u06CC",
117
+ "\u0627\u06A9\u0628\u0631\u06CC",
118
+ "\u0627\u0645\u06CC\u0646\u06CC",
119
+ "\u062C\u0639\u0641\u0631\u06CC",
120
+ "\u062D\u0633\u06CC\u0646\u06CC",
121
+ "\u0631\u0636\u0627\u06CC\u06CC",
122
+ "\u0635\u0627\u062F\u0642\u06CC",
123
+ "\u0637\u0627\u0647\u0631\u06CC",
124
+ "\u06A9\u0631\u06CC\u0645\u06CC",
125
+ "\u0645\u062D\u0645\u062F\u06CC",
126
+ "\u0645\u0631\u0627\u062F\u06CC",
127
+ "\u0645\u0648\u0633\u0648\u06CC",
128
+ "\u0646\u0627\u062F\u0631\u06CC",
129
+ "\u0646\u0648\u0631\u06CC",
130
+ "\u06CC\u0648\u0633\u0641\u06CC"
131
+ ];
132
+
133
+ // src/data/phone.ts
134
+ var MOBILE_PREFIXES = [
135
+ "0900",
136
+ "0901",
137
+ "0902",
138
+ "0903",
139
+ "0904",
140
+ "0905",
141
+ "0910",
142
+ "0911",
143
+ "0912",
144
+ "0913",
145
+ "0914",
146
+ "0915",
147
+ "0916",
148
+ "0917",
149
+ "0918",
150
+ "0919",
151
+ "0920",
152
+ "0921",
153
+ "0922",
154
+ "0923",
155
+ "0930",
156
+ "0933",
157
+ "0935",
158
+ "0936",
159
+ "0937",
160
+ "0938",
161
+ "0939",
162
+ "0990",
163
+ "0991",
164
+ "0992",
165
+ "0993",
166
+ "0994"
167
+ ];
168
+ var LANDLINE_AREAS = [
169
+ { code: "011", province: "\u0645\u0627\u0632\u0646\u062F\u0631\u0627\u0646" },
170
+ { code: "013", province: "\u06AF\u06CC\u0644\u0627\u0646" },
171
+ { code: "017", province: "\u06AF\u0644\u0633\u062A\u0627\u0646" },
172
+ { code: "021", province: "\u062A\u0647\u0631\u0627\u0646" },
173
+ { code: "023", province: "\u0633\u0645\u0646\u0627\u0646" },
174
+ { code: "024", province: "\u0632\u0646\u062C\u0627\u0646" },
175
+ { code: "025", province: "\u0642\u0645" },
176
+ { code: "026", province: "\u0627\u0644\u0628\u0631\u0632" },
177
+ { code: "028", province: "\u0642\u0632\u0648\u06CC\u0646" },
178
+ { code: "031", province: "\u0627\u0635\u0641\u0647\u0627\u0646" },
179
+ { code: "034", province: "\u06A9\u0631\u0645\u0627\u0646" },
180
+ { code: "035", province: "\u06CC\u0632\u062F" },
181
+ { code: "038", province: "\u0686\u0647\u0627\u0631\u0645\u062D\u0627\u0644 \u0648 \u0628\u062E\u062A\u06CC\u0627\u0631\u06CC" },
182
+ { code: "041", province: "\u0622\u0630\u0631\u0628\u0627\u06CC\u062C\u0627\u0646 \u0634\u0631\u0642\u06CC" },
183
+ { code: "044", province: "\u0622\u0630\u0631\u0628\u0627\u06CC\u062C\u0627\u0646 \u063A\u0631\u0628\u06CC" },
184
+ { code: "045", province: "\u0627\u0631\u062F\u0628\u06CC\u0644" },
185
+ { code: "051", province: "\u062E\u0631\u0627\u0633\u0627\u0646 \u0631\u0636\u0648\u06CC" },
186
+ { code: "054", province: "\u0633\u06CC\u0633\u062A\u0627\u0646 \u0648 \u0628\u0644\u0648\u0686\u0633\u062A\u0627\u0646" },
187
+ { code: "056", province: "\u062E\u0631\u0627\u0633\u0627\u0646 \u062C\u0646\u0648\u0628\u06CC" },
188
+ { code: "058", province: "\u062E\u0631\u0627\u0633\u0627\u0646 \u0634\u0645\u0627\u0644\u06CC" },
189
+ { code: "061", province: "\u062E\u0648\u0632\u0633\u062A\u0627\u0646" },
190
+ { code: "066", province: "\u0644\u0631\u0633\u062A\u0627\u0646" },
191
+ { code: "071", province: "\u0641\u0627\u0631\u0633" },
192
+ { code: "074", province: "\u06A9\u0647\u06AF\u06CC\u0644\u0648\u06CC\u0647 \u0648 \u0628\u0648\u06CC\u0631\u0627\u062D\u0645\u062F" },
193
+ { code: "076", province: "\u0647\u0631\u0645\u0632\u06AF\u0627\u0646" },
194
+ { code: "077", province: "\u0628\u0648\u0634\u0647\u0631" },
195
+ { code: "081", province: "\u0647\u0645\u062F\u0627\u0646" },
196
+ { code: "083", province: "\u06A9\u0631\u0645\u0627\u0646\u0634\u0627\u0647" },
197
+ { code: "084", province: "\u0627\u06CC\u0644\u0627\u0645" },
198
+ { code: "086", province: "\u0645\u0631\u06A9\u0632\u06CC" },
199
+ { code: "087", province: "\u06A9\u0631\u062F\u0633\u062A\u0627\u0646" }
200
+ ];
201
+
202
+ // src/generators/person.ts
203
+ function generateFirstName(source) {
204
+ return resolveRandom(source).pick(PERSIAN_FIRST_NAMES);
205
+ }
206
+ function generateLastName(source) {
207
+ return resolveRandom(source).pick(PERSIAN_LAST_NAMES);
208
+ }
209
+ function generateFullName(source) {
210
+ const random = resolveRandom(source);
211
+ return `${generateFirstName(random)} ${generateLastName(random)}`;
212
+ }
213
+
214
+ // src/generators/phone.ts
215
+ function generateMobile(source) {
216
+ const random = resolveRandom(source);
217
+ return `${random.pick(MOBILE_PREFIXES)}${random.digits(7)}`;
218
+ }
219
+ function generateLandline(source) {
220
+ const random = resolveRandom(source);
221
+ const area = random.pick(LANDLINE_AREAS);
222
+ const subscriberNumber = `${random.integer(2, 8)}${random.digits(7)}`;
223
+ return {
224
+ areaCode: area.code,
225
+ province: area.province,
226
+ value: `${area.code}${subscriberNumber}`
227
+ };
228
+ }
229
+
230
+ // src/generators/postal-code.ts
231
+ var POSTAL_PREFIX_DIGITS = ["1", "3", "4", "5", "6", "7", "8", "9"];
232
+ function generatePostalCode(source) {
233
+ const random = resolveRandom(source);
234
+ const prefix = Array.from(
235
+ { length: 5 },
236
+ () => random.pick(POSTAL_PREFIX_DIGITS)
237
+ ).join("");
238
+ return `${prefix}${random.digits(5)}`;
239
+ }
240
+
241
+ // src/validators/national-id.ts
242
+ var FORBIDDEN_REPEATED_NATIONAL_IDS = /* @__PURE__ */ new Set([
243
+ "0000000000",
244
+ "2222222222",
245
+ "3333333333",
246
+ "4444444444",
247
+ "5555555555",
248
+ "6666666666",
249
+ "7777777777",
250
+ "8888888888",
251
+ "9999999999"
252
+ ]);
253
+ function validateNationalId(value) {
254
+ if (!/^[0-9]{10}$/.test(value) || FORBIDDEN_REPEATED_NATIONAL_IDS.has(value)) {
255
+ return false;
256
+ }
257
+ const digits = [...value].map(Number);
258
+ const weightedSum = digits.slice(0, 9).reduce(
259
+ (total, digit, index) => total + digit * (10 - index),
260
+ 0
261
+ );
262
+ const remainder = weightedSum % 11;
263
+ const checkDigit = digits[9];
264
+ return remainder < 2 ? checkDigit === remainder : checkDigit === 11 - remainder;
265
+ }
266
+
267
+ // src/generators/national-id.ts
268
+ function calculateNationalIdCheckDigit(firstNineDigits) {
269
+ if (!/^[0-9]{9}$/.test(firstNineDigits)) {
270
+ throw new TypeError("National ID body must contain exactly 9 ASCII digits");
271
+ }
272
+ const weightedSum = [...firstNineDigits].reduce(
273
+ (total, digit, index) => total + Number(digit) * (10 - index),
274
+ 0
275
+ );
276
+ const remainder = weightedSum % 11;
277
+ return remainder < 2 ? remainder : 11 - remainder;
278
+ }
279
+ function generateNationalId(source) {
280
+ const random = resolveRandom(source);
281
+ for (let attempt = 0; attempt < 100; attempt += 1) {
282
+ const body = random.digits(9);
283
+ const value = `${body}${calculateNationalIdCheckDigit(body)}`;
284
+ if (!FORBIDDEN_REPEATED_NATIONAL_IDS.has(value)) {
285
+ return value;
286
+ }
287
+ }
288
+ throw new Error("Unable to generate an allowed national ID");
289
+ }
290
+
291
+ // src/validators/phone.ts
292
+ var MOBILE_PREFIX_SET = new Set(MOBILE_PREFIXES);
293
+ var LANDLINE_AREA_SET = new Set(
294
+ LANDLINE_AREAS.map((area) => area.code)
295
+ );
296
+ function validateMobile(value) {
297
+ return /^[0-9]{11}$/.test(value) && MOBILE_PREFIX_SET.has(value.slice(0, 4));
298
+ }
299
+ function validateLandline(value) {
300
+ return /^[0-9]{11}$/.test(value) && LANDLINE_AREA_SET.has(value.slice(0, 3)) && /^[2-8]$/.test(value[3] ?? "");
301
+ }
302
+
303
+ // src/validators/postal-code.ts
304
+ function validatePostalCode(value) {
305
+ return /^[13456789]{5}[0-9]{5}$/.test(value);
306
+ }
307
+
308
+ // src/validators/person.ts
309
+ function validatePersianName(value) {
310
+ return value.length > 0 && value.length <= 100 && value === value.trim() && !/[\u200b-\u200f\u202a-\u202e\u2060-\u206f]/u.test(value) && /^[\u0600-\u06ff]+(?: [\u0600-\u06ff]+)*$/u.test(value);
311
+ }
312
+
313
+ // src/scenarios.ts
314
+ var INVALID_SCENARIOS = {
315
+ "person.firstName": [
316
+ "empty",
317
+ "whitespace",
318
+ "too-long",
319
+ "invisible-character"
320
+ ],
321
+ "person.lastName": [
322
+ "empty",
323
+ "whitespace",
324
+ "too-long",
325
+ "invisible-character"
326
+ ],
327
+ "person.fullName": [
328
+ "empty",
329
+ "whitespace",
330
+ "too-long",
331
+ "invisible-character"
332
+ ],
333
+ "phone.mobile": [
334
+ "missing-leading-zero",
335
+ "unsupported-prefix",
336
+ "too-short",
337
+ "non-numeric",
338
+ "persian-digits"
339
+ ],
340
+ "phone.landline": [
341
+ "missing-leading-zero",
342
+ "unsupported-area",
343
+ "too-short",
344
+ "non-numeric",
345
+ "persian-digits"
346
+ ],
347
+ "identity.nationalId": [
348
+ "wrong-checksum",
349
+ "wrong-length",
350
+ "non-numeric",
351
+ "persian-digits",
352
+ "forbidden-repeated"
353
+ ],
354
+ "address.postalCode": [
355
+ "wrong-length",
356
+ "non-numeric",
357
+ "invalid-prefix",
358
+ "persian-digits"
359
+ ]
360
+ };
361
+ var VIOLATED_RULES = {
362
+ "person.firstName": {
363
+ empty: "Value must not be empty.",
364
+ whitespace: "Value must contain visible Persian letters.",
365
+ "too-long": "Value must not exceed 100 characters.",
366
+ "invisible-character": "Value must not contain zero-width characters."
367
+ },
368
+ "person.lastName": {
369
+ empty: "Value must not be empty.",
370
+ whitespace: "Value must contain visible Persian letters.",
371
+ "too-long": "Value must not exceed 100 characters.",
372
+ "invisible-character": "Value must not contain zero-width characters."
373
+ },
374
+ "person.fullName": {
375
+ empty: "Value must not be empty.",
376
+ whitespace: "Value must contain visible Persian letters.",
377
+ "too-long": "Value must not exceed 100 characters.",
378
+ "invisible-character": "Value must not contain zero-width characters."
379
+ },
380
+ "phone.mobile": {
381
+ "missing-leading-zero": "Mobile numbers must begin with 0.",
382
+ "unsupported-prefix": "Mobile prefix must be in the supported-prefix list.",
383
+ "too-short": "Mobile numbers must contain exactly 11 ASCII digits.",
384
+ "non-numeric": "Mobile numbers must contain ASCII digits only.",
385
+ "persian-digits": "Mobile numbers must use ASCII digits, not Persian digits."
386
+ },
387
+ "phone.landline": {
388
+ "missing-leading-zero": "Landlines must begin with the trunk prefix 0.",
389
+ "unsupported-area": "Landline area code must be supported.",
390
+ "too-short": "Landlines must contain exactly 11 ASCII digits.",
391
+ "non-numeric": "Landlines must contain ASCII digits only.",
392
+ "persian-digits": "Landlines must use ASCII digits, not Persian digits."
393
+ },
394
+ "identity.nationalId": {
395
+ "wrong-checksum": "The final digit must satisfy the Mod-11 checksum.",
396
+ "wrong-length": "National IDs must contain exactly 10 ASCII digits.",
397
+ "non-numeric": "National IDs must contain ASCII digits only.",
398
+ "persian-digits": "National IDs must use ASCII digits, not Persian digits.",
399
+ "forbidden-repeated": "This repeated-digit value is explicitly forbidden."
400
+ },
401
+ "address.postalCode": {
402
+ "wrong-length": "Postal codes must contain exactly 10 ASCII digits.",
403
+ "non-numeric": "Postal codes must contain ASCII digits only.",
404
+ "invalid-prefix": "The first five postal-code digits must exclude 0 and 2.",
405
+ "persian-digits": "Postal codes must use ASCII digits, not Persian digits."
406
+ }
407
+ };
408
+
409
+ // src/persian-mock.ts
410
+ var PERSIAN_DIGITS = "\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9";
411
+ function toPersianDigits(value) {
412
+ return value.replace(/[0-9]/g, (digit) => PERSIAN_DIGITS[Number(digit)] ?? digit);
413
+ }
414
+ function validValue(type, random) {
415
+ switch (type) {
416
+ case "person.firstName":
417
+ return generateFirstName(random);
418
+ case "person.lastName":
419
+ return generateLastName(random);
420
+ case "person.fullName":
421
+ return generateFullName(random);
422
+ case "phone.mobile":
423
+ return generateMobile(random);
424
+ case "phone.landline":
425
+ return generateLandline(random).value;
426
+ case "identity.nationalId":
427
+ return generateNationalId(random);
428
+ case "address.postalCode":
429
+ return generatePostalCode(random);
430
+ }
431
+ }
432
+ function invalidPersonValue(valid, scenario) {
433
+ switch (scenario) {
434
+ case "empty":
435
+ return "";
436
+ case "whitespace":
437
+ return " ";
438
+ case "too-long":
439
+ return "\u0622".repeat(101);
440
+ case "invisible-character":
441
+ return `${valid}\u200B`;
442
+ default:
443
+ throw new RangeError(`Unsupported person scenario: ${scenario}`);
444
+ }
445
+ }
446
+ function invalidMobileValue(valid, scenario) {
447
+ switch (scenario) {
448
+ case "missing-leading-zero":
449
+ return valid.slice(1);
450
+ case "unsupported-prefix":
451
+ return `0988${valid.slice(4)}`;
452
+ case "too-short":
453
+ return valid.slice(0, -1);
454
+ case "non-numeric":
455
+ return `${valid.slice(0, -1)}x`;
456
+ case "persian-digits":
457
+ return toPersianDigits(valid);
458
+ default:
459
+ throw new RangeError(`Unsupported mobile scenario: ${scenario}`);
460
+ }
461
+ }
462
+ function invalidLandlineValue(valid, scenario) {
463
+ switch (scenario) {
464
+ case "missing-leading-zero":
465
+ return valid.slice(1);
466
+ case "unsupported-area":
467
+ return `099${valid.slice(3)}`;
468
+ case "too-short":
469
+ return valid.slice(0, -1);
470
+ case "non-numeric":
471
+ return `${valid.slice(0, -1)}x`;
472
+ case "persian-digits":
473
+ return toPersianDigits(valid);
474
+ default:
475
+ throw new RangeError(`Unsupported landline scenario: ${scenario}`);
476
+ }
477
+ }
478
+ function invalidNationalIdValue(valid, scenario) {
479
+ switch (scenario) {
480
+ case "wrong-checksum": {
481
+ const checkDigit = Number(valid.at(-1));
482
+ return `${valid.slice(0, -1)}${(checkDigit + 1) % 10}`;
483
+ }
484
+ case "wrong-length":
485
+ return valid.slice(0, -1);
486
+ case "non-numeric":
487
+ return `${valid.slice(0, -1)}x`;
488
+ case "persian-digits":
489
+ return toPersianDigits(valid);
490
+ case "forbidden-repeated":
491
+ return "0000000000";
492
+ default:
493
+ throw new RangeError(`Unsupported national-ID scenario: ${scenario}`);
494
+ }
495
+ }
496
+ function invalidPostalCodeValue(valid, scenario) {
497
+ switch (scenario) {
498
+ case "wrong-length":
499
+ return valid.slice(0, -1);
500
+ case "non-numeric":
501
+ return `${valid.slice(0, -1)}x`;
502
+ case "invalid-prefix":
503
+ return `0${valid.slice(1)}`;
504
+ case "persian-digits":
505
+ return toPersianDigits(valid);
506
+ default:
507
+ throw new RangeError(`Unsupported postal-code scenario: ${scenario}`);
508
+ }
509
+ }
510
+ function invalidValue(type, valid, scenario) {
511
+ if (type.startsWith("person.")) {
512
+ return invalidPersonValue(valid, scenario);
513
+ }
514
+ switch (type) {
515
+ case "phone.mobile":
516
+ return invalidMobileValue(valid, scenario);
517
+ case "phone.landline":
518
+ return invalidLandlineValue(valid, scenario);
519
+ case "identity.nationalId":
520
+ return invalidNationalIdValue(valid, scenario);
521
+ case "address.postalCode":
522
+ return invalidPostalCodeValue(valid, scenario);
523
+ default:
524
+ throw new RangeError(`Unsupported field type: ${type}`);
525
+ }
526
+ }
527
+ function generateCase(type, mode, scenario, random) {
528
+ const base = validValue(type, random);
529
+ if (mode === "valid") {
530
+ return { type, value: base, expectedValid: true };
531
+ }
532
+ const supported = INVALID_SCENARIOS[type];
533
+ const selected = scenario ?? supported[0];
534
+ if (selected === void 0 || !supported.includes(selected)) {
535
+ throw new RangeError(
536
+ `Unsupported scenario "${String(selected)}" for ${type}. Expected one of: ${supported.join(", ")}`
537
+ );
538
+ }
539
+ return {
540
+ type,
541
+ value: invalidValue(type, base, selected),
542
+ expectedValid: false,
543
+ scenario: selected,
544
+ violatedRule: VIOLATED_RULES[type][selected] ?? "Documented field rule."
545
+ };
546
+ }
547
+ function fieldCase(type, options = {}) {
548
+ const random = createRandom(options.seed);
549
+ return generateCase(type, options.mode ?? "valid", options.mode === "invalid" ? options.scenario : void 0, random);
550
+ }
551
+ var persianMock = {
552
+ field(type, options = {}) {
553
+ return fieldCase(type, options).value;
554
+ },
555
+ case(type, options = {}) {
556
+ return fieldCase(type, options);
557
+ },
558
+ edgeCases(type, seed) {
559
+ const random = createRandom(seed);
560
+ return INVALID_SCENARIOS[type].map(
561
+ (scenario) => generateCase(type, "invalid", scenario, random)
562
+ );
563
+ },
564
+ generate(schema, options = {}) {
565
+ const random = createRandom(options.seed);
566
+ const result = {};
567
+ for (const [key, definition] of Object.entries(schema)) {
568
+ const mode = definition.mode ?? options.mode ?? "valid";
569
+ const generated = generateCase(
570
+ definition.type,
571
+ mode,
572
+ mode === "invalid" ? definition.scenario : void 0,
573
+ random
574
+ );
575
+ result[key] = generated.value;
576
+ }
577
+ return result;
578
+ }
579
+ };
580
+ // Annotate the CommonJS export names for ESM import in node:
581
+ 0 && (module.exports = {
582
+ FORBIDDEN_REPEATED_NATIONAL_IDS,
583
+ INVALID_SCENARIOS,
584
+ LANDLINE_AREAS,
585
+ MOBILE_PREFIXES,
586
+ PERSIAN_FIRST_NAMES,
587
+ PERSIAN_LAST_NAMES,
588
+ VIOLATED_RULES,
589
+ calculateNationalIdCheckDigit,
590
+ createRandom,
591
+ generateFirstName,
592
+ generateFullName,
593
+ generateLandline,
594
+ generateLastName,
595
+ generateMobile,
596
+ generateNationalId,
597
+ generatePostalCode,
598
+ persianMock,
599
+ resolveRandom,
600
+ validateLandline,
601
+ validateMobile,
602
+ validateNationalId,
603
+ validatePersianName,
604
+ validatePostalCode
605
+ });
606
+ //# sourceMappingURL=index.cjs.map