zod-ir 1.4.0 → 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/README.md +142 -140
- package/dist/index.d.mts +92 -47
- package/dist/index.d.ts +92 -47
- 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 +2 -1
package/README.md
CHANGED
|
@@ -1,44 +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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
- 🌍 **Bilingual:** Built-in error messages in **Persian** and **English**.
|
|
28
|
+
## Why zod-ir? 🚀
|
|
29
|
+
|
|
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.
|
|
42
42
|
|
|
43
43
|
---
|
|
44
44
|
|
|
@@ -52,160 +52,162 @@ pnpm add zod zod-ir
|
|
|
52
52
|
yarn add zod zod-ir
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
## Usage
|
|
55
|
+
## Usage Examples 💡
|
|
56
|
+
|
|
57
|
+
1. Smart Financial Validation (New 🌟)
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
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!
|
|
59
60
|
|
|
60
61
|
```typescript
|
|
61
62
|
import { z } from "zod";
|
|
62
|
-
import {
|
|
63
|
-
zMelliCode,
|
|
64
|
-
zIranianMobile,
|
|
65
|
-
zCardNumber,
|
|
66
|
-
zBillId,
|
|
67
|
-
zPaymentId,
|
|
68
|
-
zPlateNumber,
|
|
69
|
-
preprocessNumber,
|
|
70
|
-
} from "zod-ir";
|
|
63
|
+
import { zFinancial, getFinancialInfo } from "zod-ir";
|
|
71
64
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
// 1. Validation Schema
|
|
66
|
+
const schema = z.object({
|
|
67
|
+
destination: zFinancial({ message: "Invalid Card or Sheba" }),
|
|
68
|
+
});
|
|
75
69
|
|
|
76
|
-
|
|
77
|
-
|
|
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
|
+
```
|
|
78
90
|
|
|
79
|
-
|
|
80
|
-
card: zCardNumber(),
|
|
91
|
+
2. Crypto Wallet Validation (New 💎)
|
|
81
92
|
|
|
82
|
-
|
|
83
|
-
plate: zPlateNumber(),
|
|
93
|
+
Perfect for Fintech and Exchange apps. Supports TRC20 (USDT), ERC20, and BTC.
|
|
84
94
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
```typescript
|
|
96
|
+
import { zCrypto, getCryptoInfo } from "zod-ir";
|
|
97
|
+
|
|
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
|
+
}),
|
|
88
107
|
});
|
|
108
|
+
|
|
109
|
+
const details = getCryptoInfo("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t");
|
|
110
|
+
/* Output:
|
|
111
|
+
{
|
|
112
|
+
ticker: "TRX",
|
|
113
|
+
network: "TRC20",
|
|
114
|
+
isValid: true
|
|
115
|
+
}
|
|
116
|
+
*/
|
|
89
117
|
```
|
|
90
118
|
|
|
91
|
-
|
|
92
|
-
|
|
119
|
+
3. Jalali Date Validation (New 📅)
|
|
120
|
+
|
|
121
|
+
Validates Persian dates mathematically (checking days in month & leap years).
|
|
93
122
|
|
|
94
123
|
```typescript
|
|
95
|
-
import {
|
|
96
|
-
getBankInfo,
|
|
97
|
-
getMobileOperator,
|
|
98
|
-
getBillInfo,
|
|
99
|
-
getPlateInfo,
|
|
100
|
-
} from "zod-ir";
|
|
124
|
+
import { zJalaliDate } from "zod-ir";
|
|
101
125
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
console.log(bank.name); // "Melli"
|
|
106
|
-
console.log(bank.label); // "ملی"
|
|
107
|
-
console.log(bank.color); // "#EF3F3E" (Great for UI backgrounds!)
|
|
108
|
-
console.log(bank.logo); // URL to bank logo
|
|
109
|
-
}
|
|
126
|
+
const schema = z.object({
|
|
127
|
+
birthDate: zJalaliDate({ message: "Invalid date" }),
|
|
128
|
+
});
|
|
110
129
|
|
|
111
|
-
//
|
|
112
|
-
|
|
113
|
-
if (plate) {
|
|
114
|
-
console.log(plate.province); // "اصفهان"
|
|
115
|
-
console.log(plate.city); // "نایین"
|
|
116
|
-
}
|
|
130
|
+
// ✅ Valid (Leap year)
|
|
131
|
+
schema.parse({ birthDate: "1403/12/30" });
|
|
117
132
|
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
const bill = getBillInfo("9006117002129", "60240335");
|
|
121
|
-
if (bill) {
|
|
122
|
-
console.log(bill.type.label); // "برق"
|
|
123
|
-
console.log(bill.formattedAmount); // "602,000" (Rials)
|
|
124
|
-
console.log(bill.isValid); // true
|
|
125
|
-
}
|
|
133
|
+
// ❌ Invalid (1402 is not a leap year)
|
|
134
|
+
schema.parse({ birthDate: "1402/12/30" });
|
|
126
135
|
```
|
|
127
136
|
|
|
128
|
-
|
|
137
|
+
4. Comprehensive Form Example
|
|
138
|
+
|
|
139
|
+
A full registration form handling Auto-fix (Persian digits), Mobile, and National Code.
|
|
129
140
|
|
|
130
141
|
```typescript
|
|
131
|
-
import { useForm } from "react-hook-form";
|
|
132
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
133
142
|
import { z } from "zod";
|
|
134
|
-
import {
|
|
143
|
+
import {
|
|
144
|
+
zMelliCode,
|
|
145
|
+
zIranianMobile,
|
|
146
|
+
zCardNumber,
|
|
147
|
+
zBillId,
|
|
148
|
+
zPaymentId,
|
|
149
|
+
zPlateNumber,
|
|
150
|
+
preprocessNumber, // Converts ۱۲۳ -> 123
|
|
151
|
+
} from "zod-ir";
|
|
135
152
|
|
|
136
|
-
const
|
|
137
|
-
//
|
|
138
|
-
|
|
139
|
-
});
|
|
153
|
+
const UserSchema = z.object({
|
|
154
|
+
// Auto-convert Persian digits before validation
|
|
155
|
+
nationalCode: preprocessNumber(zMelliCode()),
|
|
140
156
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return (
|
|
151
|
-
<form onSubmit={handleSubmit((d) => console.log(d))}>
|
|
152
|
-
<input
|
|
153
|
-
{...register("nationalId")}
|
|
154
|
-
placeholder="کد ملی (حتی فارسی)"
|
|
155
|
-
dir="auto"
|
|
156
|
-
/>
|
|
157
|
-
<p style={{ color: "red" }}>{errors.nationalId?.message}</p>
|
|
158
|
-
<button type="submit">Submit</button>
|
|
159
|
-
</form>
|
|
160
|
-
);
|
|
161
|
-
}
|
|
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
|
+
});
|
|
162
165
|
```
|
|
163
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
|
+
|
|
164
180
|
## API Reference 📚
|
|
165
181
|
|
|
166
|
-
|
|
182
|
+
Identity & Contact
|
|
183
|
+
| Validator | Description |
|
|
167
184
|
| :----------------- | :----------------------------------------------------------------- |
|
|
168
|
-
| `zMelliCode`
|
|
169
|
-
| `zShenaseMelli`
|
|
170
|
-
| `
|
|
171
|
-
| `zIranianMobile`
|
|
172
|
-
| `
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
|
176
|
-
|
|
|
177
|
-
| `
|
|
178
|
-
| `
|
|
179
|
-
| `
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
| Name | Type | Description |
|
|
186
|
-
| :----------- | :-------------------- | :--------------------------------------------------------- |
|
|
187
|
-
| `message` | `string` | Custom error message to display when validation fails. |
|
|
188
|
-
| `locale` | `"fa"`, `"en"` | Language for the default error message (defaults to "fa"). |
|
|
189
|
-
| `strictZero` | `boolean`, `optional` | (Mobile Only) If true, input must start with 0. |
|
|
190
|
-
|
|
191
|
-
## Metadata Helpers (New)
|
|
192
|
-
|
|
193
|
-
| Function | Return Type | Description |
|
|
194
|
-
| :--------------------------- | :------------------------------------------- | ------------------------------------------------------------------------------ |
|
|
195
|
-
| `getBankInfo(card)` | `{ name, label, color, logo, formatted }` | Returns bank details including **Logo URL** from card number.number. |
|
|
196
|
-
| `getMobileOperator(mobile)` | `{ name, label, logo }` | Returns operator (MCI, Irancell...) including **Logo URL** from mobile number. |
|
|
197
|
-
| `getBillInfo(billId, payId)` | `{ type, amount, formattedAmount, isValid }` | Bill type (Water/Gas...), calculates amount. number. |
|
|
198
|
-
| `getPlateInfo(plate)` | `{ province, city }` | Province and City of the plate. number. |
|
|
199
|
-
| `verifyAndNormalize(str)` | `string` | Converts Persian/Arabic digits & chars (ي, ك) to standard English. |
|
|
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) |
|
|
200
202
|
|
|
201
203
|
## Contributing
|
|
202
204
|
|
|
203
|
-
Contributions are welcome!
|
|
204
|
-
|
|
205
|
-
This project uses PNPM. To get started, clone the repo and run:
|
|
205
|
+
Contributions are welcome! This project uses PNPM.
|
|
206
206
|
|
|
207
207
|
```bash
|
|
208
|
+
git clone https://github.com/Reza-kh80/zod-ir.git
|
|
208
209
|
pnpm install
|
|
210
|
+
pnpm test
|
|
209
211
|
```
|
|
210
212
|
|
|
211
213
|
## Credits 🙏
|
package/dist/index.d.mts
CHANGED
|
@@ -1,52 +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 isBillIdValid(billId: string): boolean;
|
|
19
|
-
declare function isPaymentIdValid(paymentId: string, billId: string): boolean;
|
|
20
|
-
type BillInfo = {
|
|
21
|
-
type: {
|
|
22
|
-
label: string;
|
|
23
|
-
slug: string;
|
|
24
|
-
color: string;
|
|
25
|
-
logo: string;
|
|
26
|
-
};
|
|
27
|
-
amount: number;
|
|
28
|
-
formattedAmount: string;
|
|
29
|
-
isValid: boolean;
|
|
30
|
-
} | null;
|
|
31
|
-
declare function getBillInfo(billId: string, paymentId?: string): BillInfo;
|
|
32
|
-
type PlateInfo = {
|
|
33
|
-
province: string;
|
|
34
|
-
city: string;
|
|
35
|
-
isValid: boolean;
|
|
36
|
-
} | null;
|
|
37
|
-
declare function getPlateInfo(plate: string): PlateInfo;
|
|
38
|
-
declare function isPlateNumber(plate: string): boolean;
|
|
39
|
-
declare function isMelliCode(code: string): boolean;
|
|
40
|
-
declare function isShenaseMelli(code: string): boolean;
|
|
41
|
-
declare function isPassport(code: string): boolean;
|
|
42
|
-
declare function isCardNumber(code: string): boolean;
|
|
43
|
-
interface MobileValidationOptions {
|
|
44
|
-
strictZero?: boolean | "optional";
|
|
45
|
-
}
|
|
46
|
-
declare function isIranianMobile(mobile: string, { strictZero }?: MobileValidationOptions): boolean;
|
|
47
|
-
declare function isSheba(code: string): boolean;
|
|
48
|
-
declare function isPostalCode(code: string): boolean;
|
|
49
|
-
declare function isLandline(code: string): boolean;
|
|
50
4
|
|
|
51
5
|
declare const ERROR_MESSAGES: {
|
|
52
6
|
readonly fa: {
|
|
@@ -61,6 +15,9 @@ declare const ERROR_MESSAGES: {
|
|
|
61
15
|
readonly billId: "شناسه قبض نامعتبر است";
|
|
62
16
|
readonly paymentId: "شناسه پرداخت نامعتبر است";
|
|
63
17
|
readonly plateNumber: "پلاک خودرو نامعتبر است";
|
|
18
|
+
readonly date: "تاریخ وارد شده نامعتبر است";
|
|
19
|
+
readonly financial: "شماره کارت یا شبا معتبر نیست";
|
|
20
|
+
readonly crypto: "آدرس کیف پول معتبر نیست";
|
|
64
21
|
};
|
|
65
22
|
readonly en: {
|
|
66
23
|
readonly melliCode: "Invalid national code";
|
|
@@ -74,6 +31,9 @@ declare const ERROR_MESSAGES: {
|
|
|
74
31
|
readonly billId: "Invalid Bill ID";
|
|
75
32
|
readonly paymentId: "Invalid Payment ID";
|
|
76
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";
|
|
77
37
|
};
|
|
78
38
|
};
|
|
79
39
|
type Language = keyof typeof ERROR_MESSAGES;
|
|
@@ -82,6 +42,88 @@ interface BaseOptions {
|
|
|
82
42
|
locale?: Language;
|
|
83
43
|
}
|
|
84
44
|
|
|
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
|
+
|
|
85
127
|
declare const zMelliCode: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
86
128
|
declare const zShenaseMelli: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
87
129
|
declare const zPassport: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -96,6 +138,9 @@ declare const zLandline: (options?: BaseOptions) => z.ZodEffects<z.ZodString, st
|
|
|
96
138
|
declare const zBillId: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
97
139
|
declare const zPaymentId: (options?: BaseOptions) => z.ZodEffects<z.ZodString, string, string>;
|
|
98
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>;
|
|
99
144
|
declare const preprocessNumber: (schema: z.ZodTypeAny) => z.ZodEffects<z.ZodTypeAny, any, unknown>;
|
|
100
145
|
|
|
101
|
-
export { type BankInfo, type BaseOptions, type BillInfo, type OperatorInfo, type PlateInfo, getBankInfo, getBillInfo, getMobileOperator, getPlateInfo, isBillIdValid, isCardNumber, isIranianMobile, isLandline, isMelliCode, isPassport, isPaymentIdValid, isPlateNumber, isPostalCode, isSheba, isShenaseMelli, preprocessNumber, verifyAndNormalize, zBillId, zCardNumber, zIranianMobile, zLandline, zMelliCode, zPassport, zPaymentId, zPlateNumber, 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 };
|