zod-ir 1.3.2 → 1.5.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/LICENSE +1 -1
- package/README.md +149 -130
- package/dist/index.d.mts +110 -35
- package/dist/index.d.ts +110 -35
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -11
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
+
<img src="zod-ir-logo.png" width="120" alt="zod-ir logo" style="border-radius: 15px" />
|
|
2
3
|
<h1>zod-ir</h1>
|
|
3
4
|
<p>
|
|
4
|
-
<strong>
|
|
5
|
+
<strong>The Ultimate Zod Extension for Iranian Data Structures</strong>
|
|
5
6
|
</p>
|
|
6
7
|
<p>
|
|
7
|
-
|
|
8
|
+
Validation for National Code, Bank Cards, Sheba, Bills, License Plates, Crypto, and more.
|
|
8
9
|
<br />
|
|
9
|
-
|
|
10
|
+
Lightweight. Zero Dependencies. Type-Safe.
|
|
10
11
|
</p>
|
|
11
12
|
|
|
12
13
|
<p>
|
|
13
14
|
<a href="https://www.npmjs.com/package/zod-ir">
|
|
14
|
-
<img src="https://img.shields.io/npm/v/zod-ir?style=flat-square&color=
|
|
15
|
+
<img src="https://img.shields.io/npm/v/zod-ir?style=flat-square&color=3b82f6" alt="npm version" />
|
|
15
16
|
</a>
|
|
16
17
|
<a href="https://bundlephobia.com/result?p=zod-ir">
|
|
17
|
-
<img src="https://img.shields.io/bundlephobia/minzip/zod-ir?style=flat-square&color=
|
|
18
|
+
<img src="https://img.shields.io/bundlephobia/minzip/zod-ir?style=flat-square&color=10b981" alt="bundle size" />
|
|
18
19
|
</a>
|
|
19
20
|
<a href="https://github.com/Reza-kh80/zod-ir/blob/main/LICENSE">
|
|
20
|
-
<img src="https://img.shields.io/npm/l/zod-ir?style=flat-square&color=
|
|
21
|
+
<img src="https://img.shields.io/npm/l/zod-ir?style=flat-square&color=f59e0b" alt="license" />
|
|
21
22
|
</a>
|
|
22
23
|
</p>
|
|
23
24
|
</div>
|
|
24
25
|
|
|
25
26
|
<hr />
|
|
26
27
|
|
|
27
|
-
##
|
|
28
|
+
## Why zod-ir? 🚀
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
30
|
+
Building forms in Iran requires specific validations (National Code algorithm, Bank Card Luhn, etc.). `zod-ir` brings these natively into **Zod**, with added superpowers like **Metadata Extraction** (Bank Names, Logos, Bill Types).
|
|
31
|
+
|
|
32
|
+
### Key Features ✨
|
|
33
|
+
|
|
34
|
+
- 🧠 **Smart Financial Validation:** Auto-detects **Card Number** vs **Sheba (IBAN)** and returns Bank Info & Logo.
|
|
35
|
+
- 📅 **Jalali Date (Solar Hijri):** Validates Persian dates with precise **Leap Year (Kabise)** calculation.
|
|
36
|
+
- 💎 **Crypto Support:** Validates **TRC20 (Tether)**, **ERC20**, and **Bitcoin** addresses.
|
|
37
|
+
- 💳 **Banking:** Validates Card Numbers & Sheba (ISO 7064).
|
|
38
|
+
- 🚗 **Vehicle:** Validates License Plates and detects **Province/City**.
|
|
39
|
+
- 🧾 **Utility Bills:** Validates Bill ID/Payment ID and calculates the **Amount**.
|
|
40
|
+
- 🆔 **Identity:** National Code (Melli Code), Legal Person ID (Shenase Melli), Passport.
|
|
41
|
+
- 📱 **Contact:** Mobile (MCI, Irancell...), Landline, Postal Code.
|
|
40
42
|
|
|
41
43
|
---
|
|
42
44
|
|
|
@@ -45,151 +47,168 @@
|
|
|
45
47
|
```bash
|
|
46
48
|
npm install zod zod-ir
|
|
47
49
|
# or
|
|
50
|
+
pnpm add zod zod-ir
|
|
51
|
+
# or
|
|
48
52
|
yarn add zod zod-ir
|
|
49
53
|
```
|
|
50
54
|
|
|
51
|
-
## Usage
|
|
55
|
+
## Usage Examples 💡
|
|
56
|
+
|
|
57
|
+
1. Smart Financial Validation (New 🌟)
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
This example shows how to validate a form and automatically convert Persian digits (e.g., ۰۹۱۲) to English.
|
|
59
|
+
Don't ask users for "Card" or "Sheba" separately. Use zFinancial to accept both!
|
|
55
60
|
|
|
56
61
|
```typescript
|
|
57
62
|
import { z } from "zod";
|
|
58
|
-
import {
|
|
59
|
-
zMelliCode,
|
|
60
|
-
zShenaseMelli,
|
|
61
|
-
zIranianMobile,
|
|
62
|
-
zCardNumber,
|
|
63
|
-
zSheba,
|
|
64
|
-
zPassport,
|
|
65
|
-
preprocessNumber,
|
|
66
|
-
} from "zod-ir";
|
|
63
|
+
import { zFinancial, getFinancialInfo } from "zod-ir";
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
// 1. Validation Schema
|
|
66
|
+
const schema = z.object({
|
|
67
|
+
destination: zFinancial({ message: "Invalid Card or Sheba" }),
|
|
68
|
+
});
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
// 2. Extract Metadata (Bank Name, Logo, Type)
|
|
71
|
+
const info = getFinancialInfo("6037991155667788");
|
|
72
|
+
// OR
|
|
73
|
+
const infoSheba = getFinancialInfo("IR120170000000123456789012");
|
|
74
|
+
|
|
75
|
+
console.log(info);
|
|
76
|
+
/* Output:
|
|
77
|
+
{
|
|
78
|
+
type: "card", // or "sheba"
|
|
79
|
+
isValid: true,
|
|
80
|
+
bank: {
|
|
81
|
+
name: "Melli",
|
|
82
|
+
label: "ملی",
|
|
83
|
+
color: "#EF3F3E",
|
|
84
|
+
logo: "https://.../melli.svg",
|
|
85
|
+
formatted: "6037-9911-..."
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
*/
|
|
89
|
+
```
|
|
74
90
|
|
|
75
|
-
|
|
76
|
-
mobile: zIranianMobile({ strictZero: true }),
|
|
91
|
+
2. Crypto Wallet Validation (New 💎)
|
|
77
92
|
|
|
78
|
-
|
|
79
|
-
card: zCardNumber(),
|
|
93
|
+
Perfect for Fintech and Exchange apps. Supports TRC20 (USDT), ERC20, and BTC.
|
|
80
94
|
|
|
81
|
-
|
|
82
|
-
|
|
95
|
+
```typescript
|
|
96
|
+
import { zCrypto, getCryptoInfo } from "zod-ir";
|
|
83
97
|
|
|
84
|
-
|
|
85
|
-
|
|
98
|
+
const schema = z.object({
|
|
99
|
+
// Accept any valid wallet (TRX, ETH, BTC)
|
|
100
|
+
anyWallet: zCrypto(),
|
|
101
|
+
|
|
102
|
+
// Strict: Accept ONLY Tether (TRC20)
|
|
103
|
+
usdtWallet: zCrypto({
|
|
104
|
+
ticker: "TRX",
|
|
105
|
+
message: "Only TRC20 addresses allowed",
|
|
106
|
+
}),
|
|
86
107
|
});
|
|
87
108
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
card: "6362147010005732",
|
|
95
|
-
iban: "IR330620000000202901868005",
|
|
96
|
-
passport: "A12345678",
|
|
97
|
-
});
|
|
98
|
-
console.log("Valid Data:", result);
|
|
99
|
-
} catch (err) {
|
|
100
|
-
console.log(err);
|
|
109
|
+
const details = getCryptoInfo("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t");
|
|
110
|
+
/* Output:
|
|
111
|
+
{
|
|
112
|
+
ticker: "TRX",
|
|
113
|
+
network: "TRC20",
|
|
114
|
+
isValid: true
|
|
101
115
|
}
|
|
116
|
+
*/
|
|
102
117
|
```
|
|
103
118
|
|
|
104
|
-
|
|
105
|
-
|
|
119
|
+
3. Jalali Date Validation (New 📅)
|
|
120
|
+
|
|
121
|
+
Validates Persian dates mathematically (checking days in month & leap years).
|
|
106
122
|
|
|
107
123
|
```typescript
|
|
108
|
-
import {
|
|
109
|
-
|
|
110
|
-
// --- Bank Info ---
|
|
111
|
-
const bank = getBankInfo("6037991155667788");
|
|
112
|
-
if (bank) {
|
|
113
|
-
console.log(bank.name); // "Melli"
|
|
114
|
-
console.log(bank.label); // "ملی"
|
|
115
|
-
console.log(bank.color); // "#EF3F3E" (Great for UI backgrounds!)
|
|
116
|
-
console.log(bank.formatted); // "6037-9911-5566-7788"
|
|
117
|
-
}
|
|
124
|
+
import { zJalaliDate } from "zod-ir";
|
|
118
125
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
const schema = z.object({
|
|
127
|
+
birthDate: zJalaliDate({ message: "Invalid date" }),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// ✅ Valid (Leap year)
|
|
131
|
+
schema.parse({ birthDate: "1403/12/30" });
|
|
132
|
+
|
|
133
|
+
// ❌ Invalid (1402 is not a leap year)
|
|
134
|
+
schema.parse({ birthDate: "1402/12/30" });
|
|
124
135
|
```
|
|
125
136
|
|
|
126
|
-
|
|
137
|
+
4. Comprehensive Form Example
|
|
138
|
+
|
|
139
|
+
A full registration form handling Auto-fix (Persian digits), Mobile, and National Code.
|
|
127
140
|
|
|
128
141
|
```typescript
|
|
129
|
-
import { useForm } from "react-hook-form";
|
|
130
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
131
142
|
import { z } from "zod";
|
|
132
|
-
import {
|
|
143
|
+
import {
|
|
144
|
+
zMelliCode,
|
|
145
|
+
zIranianMobile,
|
|
146
|
+
zCardNumber,
|
|
147
|
+
zBillId,
|
|
148
|
+
zPaymentId,
|
|
149
|
+
zPlateNumber,
|
|
150
|
+
preprocessNumber, // Converts ۱۲۳ -> 123
|
|
151
|
+
} from "zod-ir";
|
|
133
152
|
|
|
134
|
-
const
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
});
|
|
153
|
+
const UserSchema = z.object({
|
|
154
|
+
// Auto-convert Persian digits before validation
|
|
155
|
+
nationalCode: preprocessNumber(zMelliCode()),
|
|
138
156
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return (
|
|
149
|
-
<form onSubmit={handleSubmit((d) => console.log(d))}>
|
|
150
|
-
<input
|
|
151
|
-
{...register("nationalId")}
|
|
152
|
-
placeholder="کد ملی (حتی فارسی)"
|
|
153
|
-
dir="auto"
|
|
154
|
-
/>
|
|
155
|
-
<p style={{ color: "red" }}>{errors.nationalId?.message}</p>
|
|
156
|
-
<button type="submit">Submit</button>
|
|
157
|
-
</form>
|
|
158
|
-
);
|
|
159
|
-
}
|
|
157
|
+
mobile: zIranianMobile({ strictZero: true }),
|
|
158
|
+
card: zCardNumber(),
|
|
159
|
+
plate: zPlateNumber(), // e.g. 12م345-11
|
|
160
|
+
|
|
161
|
+
// Utility Bill
|
|
162
|
+
billId: zBillId(),
|
|
163
|
+
paymentId: zPaymentId(),
|
|
164
|
+
});
|
|
160
165
|
```
|
|
161
166
|
|
|
167
|
+
## Metadata Helpers 🛠️
|
|
168
|
+
|
|
169
|
+
zod-ir isn't just for validation. It provides rich metadata for your UI.
|
|
170
|
+
| Function | Return Type | Description |
|
|
171
|
+
| :--------------------------- | :------------------------------------------- | ------------------------------------------------------------------------------ |
|
|
172
|
+
| `getFinancialInfo(val)` | `{ type, bank, isValid }` | Smart! Detects Card or Sheba, returns Bank Logo/Color. |
|
|
173
|
+
| `getBankInfo(card)` | `{ name, label, logo... }` | Details for Card Numbers. |
|
|
174
|
+
| `getCryptoInfo(addr)` | `{ ticker, network }` | Detects TRC20, ERC20, BTC networks. |
|
|
175
|
+
| `getMobileOperator(num)` | `{ name, label, logo }` | Returns Operator (MCI, Irancell...) & Logo. |
|
|
176
|
+
| `getBillInfo(id, payId)` | `{ type, amount... }` | Bill Type (Water/Gas), Amount calculation, Validity. |
|
|
177
|
+
| `getPlateInfo(plate)` | `{ province, city }` | Province and City of the license plate. |
|
|
178
|
+
| `getJalaliDateInfo(date)` | `{ year, month, isLeap }` | Deconstructs Jalali date & checks leap year. |
|
|
179
|
+
|
|
162
180
|
## API Reference 📚
|
|
163
181
|
|
|
164
|
-
|
|
182
|
+
Identity & Contact
|
|
183
|
+
| Validator | Description |
|
|
165
184
|
| :----------------- | :----------------------------------------------------------------- |
|
|
166
|
-
| `zMelliCode`
|
|
167
|
-
| `zShenaseMelli`
|
|
168
|
-
| `
|
|
169
|
-
| `zIranianMobile`
|
|
170
|
-
| `
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
|
174
|
-
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
|
181
|
-
|
|
|
182
|
-
| `
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
185
|
+
| `zMelliCode` | National Code (Code Melli) |
|
|
186
|
+
| `zShenaseMelli` | Legal Person ID (Company) |
|
|
187
|
+
| `zPassport` | Iranian Passport |
|
|
188
|
+
| `zIranianMobile` | Mobile (09xx, +989xx) |
|
|
189
|
+
| `zPostalCode` | 10-digit Postal Code |
|
|
190
|
+
|
|
191
|
+
Financial & Assets
|
|
192
|
+
| Validator | Description |
|
|
193
|
+
| :----------------- | :----------------------------------------------------------------- |
|
|
194
|
+
| `zFinancial` | Smart Input (Card OR Sheba) |
|
|
195
|
+
| `zCardNumber` | Bank Card Number (16 digits) |
|
|
196
|
+
| `zSheba` | IBAN (Sheba) |
|
|
197
|
+
| `zCrypto` | Crypto Wallet (TRX, ETH, BTC) |
|
|
198
|
+
| `zBillId` | Utility Bill ID |
|
|
199
|
+
| `zPaymentId` | Utility Payment ID |
|
|
200
|
+
| `zPlateNumber` | Vehicle License Plate |
|
|
201
|
+
| `zJalaliDate` | Persian Date (YYYY/MM/DD) |
|
|
202
|
+
|
|
203
|
+
## Contributing
|
|
204
|
+
|
|
205
|
+
Contributions are welcome! This project uses PNPM.
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
git clone https://github.com/Reza-kh80/zod-ir.git
|
|
209
|
+
pnpm install
|
|
210
|
+
pnpm test
|
|
211
|
+
```
|
|
193
212
|
|
|
194
213
|
## Credits 🙏
|
|
195
214
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,31 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
declare function verifyAndNormalize(value: string): string;
|
|
4
|
-
type BankInfo = {
|
|
5
|
-
name: string;
|
|
6
|
-
label: string;
|
|
7
|
-
color: string;
|
|
8
|
-
logo: string;
|
|
9
|
-
formatted: string;
|
|
10
|
-
} | null;
|
|
11
|
-
declare function getBankInfo(cardNumber: string): BankInfo;
|
|
12
|
-
type OperatorInfo = {
|
|
13
|
-
name: string;
|
|
14
|
-
label: string;
|
|
15
|
-
logo: string;
|
|
16
|
-
} | null;
|
|
17
|
-
declare function getMobileOperator(mobile: string): OperatorInfo;
|
|
18
|
-
declare function isMelliCode(code: string): boolean;
|
|
19
|
-
declare function isShenaseMelli(code: string): boolean;
|
|
20
|
-
declare function isPassport(code: string): boolean;
|
|
21
|
-
declare function isCardNumber(code: string): boolean;
|
|
22
|
-
interface MobileValidationOptions {
|
|
23
|
-
strictZero?: boolean | "optional";
|
|
24
|
-
}
|
|
25
|
-
declare function isIranianMobile(mobile: string, { strictZero }?: MobileValidationOptions): boolean;
|
|
26
|
-
declare function isSheba(code: string): boolean;
|
|
27
|
-
declare function isPostalCode(code: string): boolean;
|
|
28
|
-
declare function isLandline(code: string): boolean;
|
|
29
4
|
|
|
30
5
|
declare const ERROR_MESSAGES: {
|
|
31
6
|
readonly fa: {
|
|
@@ -37,6 +12,12 @@ declare const ERROR_MESSAGES: {
|
|
|
37
12
|
readonly sheba: "شماره شبا نامعتبر است";
|
|
38
13
|
readonly postalCode: "کد پستی نامعتبر است";
|
|
39
14
|
readonly landline: "شماره تلفن ثابت نامعتبر است";
|
|
15
|
+
readonly billId: "شناسه قبض نامعتبر است";
|
|
16
|
+
readonly paymentId: "شناسه پرداخت نامعتبر است";
|
|
17
|
+
readonly plateNumber: "پلاک خودرو نامعتبر است";
|
|
18
|
+
readonly date: "تاریخ وارد شده نامعتبر است";
|
|
19
|
+
readonly financial: "شماره کارت یا شبا معتبر نیست";
|
|
20
|
+
readonly crypto: "آدرس کیف پول معتبر نیست";
|
|
40
21
|
};
|
|
41
22
|
readonly en: {
|
|
42
23
|
readonly melliCode: "Invalid national code";
|
|
@@ -47,6 +28,12 @@ declare const ERROR_MESSAGES: {
|
|
|
47
28
|
readonly sheba: "Invalid Sheba (IBAN) number";
|
|
48
29
|
readonly postalCode: "Invalid postal code";
|
|
49
30
|
readonly landline: "Invalid landline number";
|
|
31
|
+
readonly billId: "Invalid Bill ID";
|
|
32
|
+
readonly paymentId: "Invalid Payment ID";
|
|
33
|
+
readonly plateNumber: "Invalid License Plate";
|
|
34
|
+
readonly date: "Invalid Date";
|
|
35
|
+
readonly financial: "Invalid Sheba (IBAN) number or card number";
|
|
36
|
+
readonly crypto: "Invalid Wallet address";
|
|
50
37
|
};
|
|
51
38
|
};
|
|
52
39
|
type Language = keyof typeof ERROR_MESSAGES;
|
|
@@ -55,17 +42,105 @@ interface BaseOptions {
|
|
|
55
42
|
locale?: Language;
|
|
56
43
|
}
|
|
57
44
|
|
|
58
|
-
declare
|
|
59
|
-
declare
|
|
60
|
-
declare
|
|
61
|
-
|
|
45
|
+
declare function isMelliCode(code: string): boolean;
|
|
46
|
+
declare function isShenaseMelli(code: string): boolean;
|
|
47
|
+
declare function isPassport(code: string): boolean;
|
|
48
|
+
|
|
49
|
+
type BankInfo = {
|
|
50
|
+
name: string;
|
|
51
|
+
label: string;
|
|
52
|
+
color: string;
|
|
53
|
+
logo: string;
|
|
54
|
+
formatted: string;
|
|
55
|
+
} | null;
|
|
56
|
+
declare function getBankInfo(cardNumber: string): BankInfo;
|
|
57
|
+
declare function isCardNumber(code: string): boolean;
|
|
58
|
+
declare function isSheba(code: string): boolean;
|
|
59
|
+
type FinancialInfo = {
|
|
60
|
+
type: "card" | "sheba" | "unknown";
|
|
61
|
+
value: string;
|
|
62
|
+
isValid: boolean;
|
|
63
|
+
bank: BankInfo;
|
|
64
|
+
} | null;
|
|
65
|
+
declare function getFinancialInfo(value: string): FinancialInfo;
|
|
66
|
+
declare function isFinancialValue(value: string): boolean;
|
|
67
|
+
|
|
68
|
+
type OperatorInfo = {
|
|
69
|
+
name: string;
|
|
70
|
+
label: string;
|
|
71
|
+
logo: string;
|
|
72
|
+
} | null;
|
|
73
|
+
declare function getMobileOperator(mobile: string): OperatorInfo;
|
|
74
|
+
interface MobileValidationOptions {
|
|
75
|
+
strictZero?: boolean | "optional";
|
|
76
|
+
}
|
|
77
|
+
declare function isIranianMobile(mobile: string, { strictZero }?: MobileValidationOptions): boolean;
|
|
78
|
+
declare function isPostalCode(code: string): boolean;
|
|
79
|
+
declare function isLandline(code: string): boolean;
|
|
80
|
+
|
|
81
|
+
type PlateInfo = {
|
|
82
|
+
province: string;
|
|
83
|
+
city: string;
|
|
84
|
+
isValid: boolean;
|
|
85
|
+
} | null;
|
|
86
|
+
declare function getPlateInfo(plate: string): PlateInfo;
|
|
87
|
+
declare function isPlateNumber(plate: string): boolean;
|
|
88
|
+
|
|
89
|
+
declare function isBillIdValid(billId: string): boolean;
|
|
90
|
+
declare function isPaymentIdValid(paymentId: string, billId: string): boolean;
|
|
91
|
+
type BillInfo = {
|
|
92
|
+
type: {
|
|
93
|
+
label: string;
|
|
94
|
+
slug: string;
|
|
95
|
+
color: string;
|
|
96
|
+
logo: string;
|
|
97
|
+
};
|
|
98
|
+
amount: number;
|
|
99
|
+
formattedAmount: string;
|
|
100
|
+
isValid: boolean;
|
|
101
|
+
} | null;
|
|
102
|
+
declare function getBillInfo(billId: string, paymentId?: string): BillInfo;
|
|
103
|
+
|
|
104
|
+
type JalaliDateInfo = {
|
|
105
|
+
year: number;
|
|
106
|
+
month: number;
|
|
107
|
+
day: number;
|
|
108
|
+
isValid: boolean;
|
|
109
|
+
isLeap: boolean;
|
|
110
|
+
} | null;
|
|
111
|
+
declare function getJalaliDateInfo(date: string): JalaliDateInfo;
|
|
112
|
+
declare function isJalaliDate(date: string): boolean;
|
|
113
|
+
|
|
114
|
+
type CryptoInfo = {
|
|
115
|
+
ticker: "TRX" | "ETH" | "BTC" | "UNKNOWN";
|
|
116
|
+
network: "TRC20" | "ERC20" | "BITCOIN" | "UNKNOWN";
|
|
117
|
+
isValid: boolean;
|
|
118
|
+
warning?: string;
|
|
119
|
+
} | null;
|
|
120
|
+
declare function getCryptoInfo(address: string): CryptoInfo;
|
|
121
|
+
declare function isCryptoAddress(address: string, ticker?: "TRX" | "ETH" | "BTC"): boolean;
|
|
122
|
+
|
|
123
|
+
interface CryptoOptions extends BaseOptions {
|
|
124
|
+
ticker?: "TRX" | "ETH" | "BTC";
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
declare const zMelliCode: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
128
|
+
declare const zShenaseMelli: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
129
|
+
declare const zPassport: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
130
|
+
declare const zCardNumber: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
62
131
|
interface MobileOptions extends BaseOptions {
|
|
63
132
|
strictZero?: boolean | "optional";
|
|
64
133
|
}
|
|
65
|
-
declare const zIranianMobile: (options?: MobileOptions) => z.ZodString
|
|
66
|
-
declare const zSheba: (options?: BaseOptions) => z.ZodString
|
|
67
|
-
declare const zPostalCode: (options?: BaseOptions) => z.ZodString
|
|
68
|
-
declare const zLandline: (options?: BaseOptions) => z.ZodString
|
|
69
|
-
declare const
|
|
134
|
+
declare const zIranianMobile: (options?: MobileOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
135
|
+
declare const zSheba: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
136
|
+
declare const zPostalCode: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
137
|
+
declare const zLandline: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
138
|
+
declare const zBillId: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
139
|
+
declare const zPaymentId: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
140
|
+
declare const zPlateNumber: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
141
|
+
declare const zJalaliDate: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
142
|
+
declare const zFinancial: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
143
|
+
declare const zCrypto: (options?: CryptoOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
144
|
+
declare const preprocessNumber: (schema: z.ZodTypeAny) => z.ZodEffects<z.ZodTypeAny, any, unknown>;
|
|
70
145
|
|
|
71
|
-
export { getBankInfo, getMobileOperator, isCardNumber, isIranianMobile, isLandline, isMelliCode, isPassport, isPostalCode, isSheba, isShenaseMelli, preprocessNumber, verifyAndNormalize, zCardNumber, zIranianMobile, zLandline, zMelliCode, zPassport, zPostalCode, zSheba, zShenaseMelli };
|
|
146
|
+
export { type BankInfo, type BaseOptions, type BillInfo, type CryptoInfo, type FinancialInfo, type JalaliDateInfo, type OperatorInfo, type PlateInfo, getBankInfo, getBillInfo, getCryptoInfo, getFinancialInfo, getJalaliDateInfo, getMobileOperator, getPlateInfo, isBillIdValid, isCardNumber, isCryptoAddress, isFinancialValue, isIranianMobile, isJalaliDate, isLandline, isMelliCode, isPassport, isPaymentIdValid, isPlateNumber, isPostalCode, isSheba, isShenaseMelli, preprocessNumber, verifyAndNormalize, zBillId, zCardNumber, zCrypto, zFinancial, zIranianMobile, zJalaliDate, zLandline, zMelliCode, zPassport, zPaymentId, zPlateNumber, zPostalCode, zSheba, zShenaseMelli };
|