persian-mock-data 0.1.1 → 0.1.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/README.en.md +0 -146
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "persian-mock-data",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Deterministic, framework-agnostic Iranian mock data generators and validators.",
5
5
  "keywords": [
6
6
  "iran",
package/README.en.md DELETED
@@ -1,146 +0,0 @@
1
- # Persian Mock Data Factory
2
-
3
- [مستندات فارسی](./README.md)
4
-
5
- A framework-agnostic TypeScript library for deterministic Iranian mock data,
6
- named invalid scenarios, and frontend form edge-case testing.
7
-
8
- > The library creates data that satisfies its **documented format and
9
- > algorithm rules**. It does not assert that a person exists, a phone is
10
- > reachable, a national ID is officially assigned, or a postal code is
11
- > deliverable.
12
-
13
- ## Project status
14
-
15
- The `0.1.0` core is implemented, but the package has not been published to npm.
16
- For local development:
17
-
18
- ```bash
19
- git clone https://github.com/Ali-Shahnoushi/persian-mock-data.git
20
- cd persian-mock-data
21
- npm install
22
- npm run build
23
- ```
24
-
25
- The build produces ESM, CommonJS, and TypeScript declarations without a UI
26
- framework dependency.
27
-
28
- ## Quick start
29
-
30
- ```ts
31
- import { persianMock } from "persian-mock-data";
32
-
33
- const user = persianMock.generate(
34
- {
35
- fullName: { type: "person.fullName" },
36
- mobile: { type: "phone.mobile" },
37
- landline: { type: "phone.landline" },
38
- nationalId: { type: "identity.nationalId" },
39
- postalCode: { type: "address.postalCode" },
40
- },
41
- { seed: 1405 },
42
- );
43
- ```
44
-
45
- The same schema and seed always produce the same object. A schema uses one
46
- shared random stream, so the entire fixture is reproducible.
47
-
48
- ### Target one validation rule
49
-
50
- ```ts
51
- const invalidId = persianMock.field("identity.nationalId", {
52
- mode: "invalid",
53
- scenario: "wrong-checksum",
54
- seed: 1405,
55
- });
56
-
57
- const explained = persianMock.case("phone.mobile", {
58
- mode: "invalid",
59
- scenario: "persian-digits",
60
- seed: 1405,
61
- });
62
-
63
- const allPostalCases = persianMock.edgeCases("address.postalCode", 1405);
64
- ```
65
-
66
- `field()` returns the raw string. `case()` and `edgeCases()` also return
67
- `expectedValid`, the scenario name, and a human-readable `violatedRule`.
68
-
69
- ## Public API
70
-
71
- | API | Purpose |
72
- | --- | --- |
73
- | `persianMock.generate(schema, options)` | Generate form-shaped raw values |
74
- | `persianMock.field(type, options)` | Generate one raw field value |
75
- | `persianMock.case(type, options)` | Generate one value with validity metadata |
76
- | `persianMock.edgeCases(type, seed)` | Generate every invalid scenario for a field |
77
- | `generateFirstName`, `generateLastName`, `generateFullName` | Generate Persian mock names |
78
- | `generateMobile`, `generateLandline` | Generate supported phone formats |
79
- | `generateNationalId`, `generatePostalCode` | Generate identity/address formats |
80
- | `validateMobile`, `validateLandline` | Validate format and supported prefixes |
81
- | `validateNationalId`, `validatePostalCode` | Validate documented rules |
82
- | `createRandom(seed)` | Compose generators with one seeded random source |
83
-
84
- Supported field types are `person.firstName`, `person.lastName`,
85
- `person.fullName`, `phone.mobile`, `phone.landline`,
86
- `identity.nationalId`, and `address.postalCode`.
87
-
88
- ## Validation contracts
89
-
90
- ### National ID
91
-
92
- `validateNationalId` implements the project owner's exact reference behavior:
93
-
94
- - The input is exactly 10 ASCII digits.
95
- - `0000000000` and repeated digits from `2222222222` through `9999999999` are
96
- rejected.
97
- - The first nine digits use weights 10 through 2.
98
- - When `weightedSum % 11` is below 2, the check digit equals that remainder;
99
- otherwise it equals `11 - remainder`.
100
- - `1111111111` is accepted, matching the reference function. A regression test
101
- protects this deliberate edge behavior.
102
-
103
- No undocumented stricter policy is silently applied.
104
-
105
- ### Mobile and landline
106
-
107
- A mobile is 11 ASCII digits and starts with an explicitly supported four-digit
108
- prefix exported as `MOBILE_PREFIXES`. A landline is 11 ASCII digits, starts
109
- with one of the three-digit areas exported as `LANDLINE_AREAS`, and has an
110
- eight-digit subscriber number beginning with 2 through 8. `generateLandline`
111
- returns matching `value`, `areaCode`, and `province` fields.
112
-
113
- These policies validate the package's supported formats; they do not prove
114
- that a number is allocated or reachable.
115
-
116
- ### Postal code
117
-
118
- The format-level policy is 10 ASCII digits with no `0` or `2` in the first five
119
- positions. It does not verify official allocation or deliverability.
120
-
121
- ## Named invalid scenarios
122
-
123
- | Field | Scenarios |
124
- | --- | --- |
125
- | Names | `empty`, `whitespace`, `too-long`, `invisible-character` |
126
- | Mobile | `missing-leading-zero`, `unsupported-prefix`, `too-short`, `non-numeric`, `persian-digits` |
127
- | Landline | `missing-leading-zero`, `unsupported-area`, `too-short`, `non-numeric`, `persian-digits` |
128
- | National ID | `wrong-checksum`, `wrong-length`, `non-numeric`, `persian-digits`, `forbidden-repeated` |
129
- | Postal code | `wrong-length`, `non-numeric`, `invalid-prefix`, `persian-digits` |
130
-
131
- TypeScript rejects scenarios that do not belong to a field. Runtime validation
132
- also throws a `RangeError` for incompatible input.
133
-
134
- ## Development
135
-
136
- ```bash
137
- npm run check
138
- ```
139
-
140
- The check runs strict type-checking, the full Vitest suite, and the production
141
- build. See [the implementation plan](./docs/IMPLEMENTATION_PLAN.md) for the
142
- phased design and verification approach.
143
-
144
- ## License
145
-
146
- [MIT](./LICENSE)