zod 4.2.0-canary.20251022T022243 → 4.2.0-canary.20251106T214242
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/package.json +1 -1
- package/src/v4/core/schemas.ts +1 -1
- package/src/v4/core/tests/locales/he.test.ts +379 -0
- package/src/v4/locales/he.ts +202 -71
- package/v4/core/schemas.cjs +1 -1
- package/v4/core/schemas.js +1 -1
- package/v4/locales/he.cjs +177 -66
- package/v4/locales/he.js +177 -66
package/src/v4/locales/he.ts
CHANGED
|
@@ -3,115 +3,246 @@ import type * as errors from "../core/errors.js";
|
|
|
3
3
|
import * as util from "../core/util.js";
|
|
4
4
|
|
|
5
5
|
const error: () => errors.$ZodErrorMap = () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
// Hebrew labels + grammatical gender
|
|
7
|
+
const TypeNames: Record<string, { label: string; gender: "m" | "f" }> = {
|
|
8
|
+
string: { label: "מחרוזת", gender: "f" },
|
|
9
|
+
number: { label: "מספר", gender: "m" },
|
|
10
|
+
boolean: { label: "ערך בוליאני", gender: "m" },
|
|
11
|
+
bigint: { label: "BigInt", gender: "m" },
|
|
12
|
+
date: { label: "תאריך", gender: "m" },
|
|
13
|
+
array: { label: "מערך", gender: "m" },
|
|
14
|
+
object: { label: "אובייקט", gender: "m" },
|
|
15
|
+
null: { label: "ערך ריק (null)", gender: "m" },
|
|
16
|
+
undefined: { label: "ערך לא מוגדר (undefined)", gender: "m" },
|
|
17
|
+
symbol: { label: "סימבול (Symbol)", gender: "m" },
|
|
18
|
+
function: { label: "פונקציה", gender: "f" },
|
|
19
|
+
map: { label: "מפה (Map)", gender: "f" },
|
|
20
|
+
set: { label: "קבוצה (Set)", gender: "f" },
|
|
21
|
+
file: { label: "קובץ", gender: "m" },
|
|
22
|
+
promise: { label: "Promise", gender: "m" },
|
|
23
|
+
NaN: { label: "NaN", gender: "m" },
|
|
24
|
+
unknown: { label: "ערך לא ידוע", gender: "m" },
|
|
25
|
+
value: { label: "ערך", gender: "m" },
|
|
11
26
|
};
|
|
12
27
|
|
|
13
|
-
|
|
28
|
+
// Sizing units for size-related messages + localized origin labels
|
|
29
|
+
const Sizable: Record<string, { unit: string; shortLabel?: string; longLabel?: string }> = {
|
|
30
|
+
string: { unit: "תווים", shortLabel: "קצר", longLabel: "ארוך" },
|
|
31
|
+
file: { unit: "בייטים", shortLabel: "קטן", longLabel: "גדול" },
|
|
32
|
+
array: { unit: "פריטים", shortLabel: "קטן", longLabel: "גדול" },
|
|
33
|
+
set: { unit: "פריטים", shortLabel: "קטן", longLabel: "גדול" },
|
|
34
|
+
number: { unit: "", shortLabel: "קטן", longLabel: "גדול" }, // no unit
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Helpers — labels, articles, and verbs
|
|
38
|
+
const typeEntry = (t?: string | null) => (t ? TypeNames[t] : undefined);
|
|
39
|
+
|
|
40
|
+
const typeLabel = (t?: string | null): string => {
|
|
41
|
+
const e = typeEntry(t);
|
|
42
|
+
if (e) return e.label;
|
|
43
|
+
// fallback: show raw string if unknown
|
|
44
|
+
return t ?? TypeNames.unknown.label;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const withDefinite = (t?: string | null): string => `ה${typeLabel(t)}`;
|
|
48
|
+
|
|
49
|
+
const verbFor = (t?: string | null): string => {
|
|
50
|
+
const e = typeEntry(t);
|
|
51
|
+
const gender = e?.gender ?? "m";
|
|
52
|
+
return gender === "f" ? "צריכה להיות" : "צריך להיות";
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const getSizing = (origin?: string | null) => {
|
|
56
|
+
if (!origin) return null;
|
|
14
57
|
return Sizable[origin] ?? null;
|
|
15
|
-
}
|
|
58
|
+
};
|
|
16
59
|
|
|
60
|
+
// Robust type parser for "received" — returns a key we understand or a constructor name
|
|
17
61
|
const parsedType = (data: any): string => {
|
|
18
62
|
const t = typeof data;
|
|
19
|
-
|
|
20
63
|
switch (t) {
|
|
21
|
-
case "number":
|
|
64
|
+
case "number":
|
|
22
65
|
return Number.isNaN(data) ? "NaN" : "number";
|
|
23
|
-
}
|
|
24
66
|
case "object": {
|
|
25
|
-
if (Array.isArray(data))
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
if (data === null) {
|
|
29
|
-
return "null";
|
|
30
|
-
}
|
|
31
|
-
|
|
67
|
+
if (Array.isArray(data)) return "array";
|
|
68
|
+
if (data === null) return "null";
|
|
32
69
|
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
33
|
-
return data.constructor.name;
|
|
70
|
+
return data.constructor.name; // keep as-is (e.g., "Date")
|
|
34
71
|
}
|
|
72
|
+
return "object";
|
|
35
73
|
}
|
|
74
|
+
default:
|
|
75
|
+
return t;
|
|
36
76
|
}
|
|
37
|
-
return t;
|
|
38
77
|
};
|
|
39
78
|
|
|
40
79
|
const Nouns: {
|
|
41
|
-
[k in $ZodStringFormats
|
|
80
|
+
[k in $ZodStringFormats]: { label: string; gender: "m" | "f" };
|
|
42
81
|
} = {
|
|
43
|
-
regex: "קלט",
|
|
44
|
-
email: "כתובת אימייל",
|
|
45
|
-
url: "כתובת רשת",
|
|
46
|
-
emoji: "אימוג'י",
|
|
47
|
-
uuid: "UUID",
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
82
|
+
regex: { label: "קלט", gender: "m" },
|
|
83
|
+
email: { label: "כתובת אימייל", gender: "f" },
|
|
84
|
+
url: { label: "כתובת רשת", gender: "f" },
|
|
85
|
+
emoji: { label: "אימוג'י", gender: "m" },
|
|
86
|
+
uuid: { label: "UUID", gender: "m" },
|
|
87
|
+
nanoid: { label: "nanoid", gender: "m" },
|
|
88
|
+
guid: { label: "GUID", gender: "m" },
|
|
89
|
+
cuid: { label: "cuid", gender: "m" },
|
|
90
|
+
cuid2: { label: "cuid2", gender: "m" },
|
|
91
|
+
ulid: { label: "ULID", gender: "m" },
|
|
92
|
+
xid: { label: "XID", gender: "m" },
|
|
93
|
+
ksuid: { label: "KSUID", gender: "m" },
|
|
94
|
+
datetime: { label: "תאריך וזמן ISO", gender: "m" },
|
|
95
|
+
date: { label: "תאריך ISO", gender: "m" },
|
|
96
|
+
time: { label: "זמן ISO", gender: "m" },
|
|
97
|
+
duration: { label: "משך זמן ISO", gender: "m" },
|
|
98
|
+
ipv4: { label: "כתובת IPv4", gender: "f" },
|
|
99
|
+
ipv6: { label: "כתובת IPv6", gender: "f" },
|
|
100
|
+
cidrv4: { label: "טווח IPv4", gender: "m" },
|
|
101
|
+
cidrv6: { label: "טווח IPv6", gender: "m" },
|
|
102
|
+
base64: { label: "מחרוזת בבסיס 64", gender: "f" },
|
|
103
|
+
base64url: { label: "מחרוזת בבסיס 64 לכתובות רשת", gender: "f" },
|
|
104
|
+
json_string: { label: "מחרוזת JSON", gender: "f" },
|
|
105
|
+
e164: { label: "מספר E.164", gender: "m" },
|
|
106
|
+
jwt: { label: "JWT", gender: "m" },
|
|
107
|
+
ends_with: { label: "קלט", gender: "m" },
|
|
108
|
+
includes: { label: "קלט", gender: "m" },
|
|
109
|
+
lowercase: { label: "קלט", gender: "m" },
|
|
110
|
+
starts_with: { label: "קלט", gender: "m" },
|
|
111
|
+
uppercase: { label: "קלט", gender: "m" },
|
|
71
112
|
};
|
|
72
113
|
|
|
73
114
|
return (issue) => {
|
|
74
115
|
switch (issue.code) {
|
|
75
|
-
case "invalid_type":
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
116
|
+
case "invalid_type": {
|
|
117
|
+
// Expected type: show without definite article for clearer Hebrew
|
|
118
|
+
const expectedKey = issue.expected as string | undefined;
|
|
119
|
+
const expected = typeLabel(expectedKey);
|
|
120
|
+
// Received: show localized label if known, otherwise constructor/raw
|
|
121
|
+
const receivedKey = parsedType(issue.input);
|
|
122
|
+
const received = TypeNames[receivedKey]?.label ?? receivedKey;
|
|
123
|
+
return `קלט לא תקין: צריך להיות ${expected}, התקבל ${received}`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
case "invalid_value": {
|
|
127
|
+
if (issue.values.length === 1) {
|
|
128
|
+
return `ערך לא תקין: הערך חייב להיות ${util.stringifyPrimitive(issue.values[0])}`;
|
|
129
|
+
}
|
|
130
|
+
// Join values with proper Hebrew formatting
|
|
131
|
+
const stringified = issue.values.map((v) => util.stringifyPrimitive(v));
|
|
132
|
+
if (issue.values.length === 2) {
|
|
133
|
+
return `ערך לא תקין: האפשרויות המתאימות הן ${stringified[0]} או ${stringified[1]}`;
|
|
134
|
+
}
|
|
135
|
+
// For 3+ values: "a", "b" או "c"
|
|
136
|
+
const lastValue = stringified[stringified.length - 1];
|
|
137
|
+
const restValues = stringified.slice(0, -1).join(", ");
|
|
138
|
+
return `ערך לא תקין: האפשרויות המתאימות הן ${restValues} או ${lastValue}`;
|
|
139
|
+
}
|
|
140
|
+
|
|
81
141
|
case "too_big": {
|
|
82
|
-
const adj = issue.inclusive ? "<=" : "<";
|
|
83
142
|
const sizing = getSizing(issue.origin);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
143
|
+
const subject = withDefinite(issue.origin ?? "value");
|
|
144
|
+
|
|
145
|
+
if (issue.origin === "string") {
|
|
146
|
+
// Special handling for strings - more natural Hebrew
|
|
147
|
+
return `${sizing?.longLabel ?? "ארוך"} מדי: ${subject} צריכה להכיל ${issue.maximum.toString()} ${sizing?.unit ?? ""} ${issue.inclusive ? "או פחות" : "לכל היותר"}`.trim();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (issue.origin === "number") {
|
|
151
|
+
// Natural Hebrew for numbers
|
|
152
|
+
const comparison = issue.inclusive ? `קטן או שווה ל-${issue.maximum}` : `קטן מ-${issue.maximum}`;
|
|
153
|
+
return `גדול מדי: ${subject} צריך להיות ${comparison}`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (issue.origin === "array" || issue.origin === "set") {
|
|
157
|
+
// Natural Hebrew for arrays and sets
|
|
158
|
+
const verb = issue.origin === "set" ? "צריכה" : "צריך";
|
|
159
|
+
const comparison = issue.inclusive
|
|
160
|
+
? `${issue.maximum} ${sizing?.unit ?? ""} או פחות`
|
|
161
|
+
: `פחות מ-${issue.maximum} ${sizing?.unit ?? ""}`;
|
|
162
|
+
return `גדול מדי: ${subject} ${verb} להכיל ${comparison}`.trim();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const adj = issue.inclusive ? "<=" : "<";
|
|
166
|
+
const be = verbFor(issue.origin ?? "value");
|
|
167
|
+
if (sizing?.unit) {
|
|
168
|
+
return `${sizing.longLabel} מדי: ${subject} ${be} ${adj}${issue.maximum.toString()} ${sizing.unit}`;
|
|
169
|
+
}
|
|
170
|
+
return `${sizing?.longLabel ?? "גדול"} מדי: ${subject} ${be} ${adj}${issue.maximum.toString()}`;
|
|
87
171
|
}
|
|
172
|
+
|
|
88
173
|
case "too_small": {
|
|
89
|
-
const adj = issue.inclusive ? ">=" : ">";
|
|
90
174
|
const sizing = getSizing(issue.origin);
|
|
91
|
-
|
|
92
|
-
|
|
175
|
+
const subject = withDefinite(issue.origin ?? "value");
|
|
176
|
+
|
|
177
|
+
if (issue.origin === "string") {
|
|
178
|
+
// Special handling for strings - more natural Hebrew
|
|
179
|
+
return `${sizing?.shortLabel ?? "קצר"} מדי: ${subject} צריכה להכיל ${issue.minimum.toString()} ${sizing?.unit ?? ""} ${issue.inclusive ? "או יותר" : "לפחות"}`.trim();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (issue.origin === "number") {
|
|
183
|
+
// Natural Hebrew for numbers
|
|
184
|
+
const comparison = issue.inclusive ? `גדול או שווה ל-${issue.minimum}` : `גדול מ-${issue.minimum}`;
|
|
185
|
+
return `קטן מדי: ${subject} צריך להיות ${comparison}`;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (issue.origin === "array" || issue.origin === "set") {
|
|
189
|
+
// Natural Hebrew for arrays and sets
|
|
190
|
+
const verb = issue.origin === "set" ? "צריכה" : "צריך";
|
|
191
|
+
|
|
192
|
+
// Special case for singular (minimum === 1)
|
|
193
|
+
if (issue.minimum === 1 && issue.inclusive) {
|
|
194
|
+
const singularPhrase = issue.origin === "set" ? "לפחות פריט אחד" : "לפחות פריט אחד";
|
|
195
|
+
return `קטן מדי: ${subject} ${verb} להכיל ${singularPhrase}`;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const comparison = issue.inclusive
|
|
199
|
+
? `${issue.minimum} ${sizing?.unit ?? ""} או יותר`
|
|
200
|
+
: `יותר מ-${issue.minimum} ${sizing?.unit ?? ""}`;
|
|
201
|
+
return `קטן מדי: ${subject} ${verb} להכיל ${comparison}`.trim();
|
|
93
202
|
}
|
|
94
203
|
|
|
95
|
-
|
|
204
|
+
const adj = issue.inclusive ? ">=" : ">";
|
|
205
|
+
const be = verbFor(issue.origin ?? "value");
|
|
206
|
+
if (sizing?.unit) {
|
|
207
|
+
return `${sizing.shortLabel} מדי: ${subject} ${be} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
208
|
+
}
|
|
209
|
+
return `${sizing?.shortLabel ?? "קטן"} מדי: ${subject} ${be} ${adj}${issue.minimum.toString()}`;
|
|
96
210
|
}
|
|
211
|
+
|
|
97
212
|
case "invalid_format": {
|
|
98
213
|
const _issue = issue as errors.$ZodStringFormatIssues;
|
|
99
|
-
|
|
100
|
-
if (_issue.format === "
|
|
101
|
-
if (_issue.format === "
|
|
102
|
-
if (_issue.format === "
|
|
103
|
-
|
|
214
|
+
// These apply to strings — use feminine grammar + ה׳ הידיעה
|
|
215
|
+
if (_issue.format === "starts_with") return `המחרוזת חייבת להתחיל ב "${_issue.prefix}"`;
|
|
216
|
+
if (_issue.format === "ends_with") return `המחרוזת חייבת להסתיים ב "${_issue.suffix}"`;
|
|
217
|
+
if (_issue.format === "includes") return `המחרוזת חייבת לכלול "${_issue.includes}"`;
|
|
218
|
+
if (_issue.format === "regex") return `המחרוזת חייבת להתאים לתבנית ${_issue.pattern}`;
|
|
219
|
+
|
|
220
|
+
// Handle gender agreement for formats
|
|
221
|
+
const nounEntry = Nouns[_issue.format];
|
|
222
|
+
const noun = nounEntry?.label ?? _issue.format;
|
|
223
|
+
const gender = nounEntry?.gender ?? "m";
|
|
224
|
+
const adjective = gender === "f" ? "תקינה" : "תקין";
|
|
225
|
+
return `${noun} לא ${adjective}`;
|
|
104
226
|
}
|
|
227
|
+
|
|
105
228
|
case "not_multiple_of":
|
|
106
229
|
return `מספר לא תקין: חייב להיות מכפלה של ${issue.divisor}`;
|
|
230
|
+
|
|
107
231
|
case "unrecognized_keys":
|
|
108
232
|
return `מפתח${issue.keys.length > 1 ? "ות" : ""} לא מזוה${issue.keys.length > 1 ? "ים" : "ה"}: ${util.joinValues(issue.keys, ", ")}`;
|
|
109
|
-
|
|
110
|
-
|
|
233
|
+
|
|
234
|
+
case "invalid_key": {
|
|
235
|
+
return `שדה לא תקין באובייקט`;
|
|
236
|
+
}
|
|
237
|
+
|
|
111
238
|
case "invalid_union":
|
|
112
239
|
return "קלט לא תקין";
|
|
113
|
-
|
|
114
|
-
|
|
240
|
+
|
|
241
|
+
case "invalid_element": {
|
|
242
|
+
const place = withDefinite(issue.origin ?? "array");
|
|
243
|
+
return `ערך לא תקין ב${place}`;
|
|
244
|
+
}
|
|
245
|
+
|
|
115
246
|
default:
|
|
116
247
|
return `קלט לא תקין`;
|
|
117
248
|
}
|
package/v4/core/schemas.cjs
CHANGED
|
@@ -758,7 +758,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
758
758
|
const keySet = def.keySet;
|
|
759
759
|
const _catchall = def.catchall._zod;
|
|
760
760
|
const t = _catchall.def.type;
|
|
761
|
-
for (const key
|
|
761
|
+
for (const key in input) {
|
|
762
762
|
if (keySet.has(key))
|
|
763
763
|
continue;
|
|
764
764
|
if (t === "never") {
|
package/v4/core/schemas.js
CHANGED
|
@@ -727,7 +727,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
727
727
|
const keySet = def.keySet;
|
|
728
728
|
const _catchall = def.catchall._zod;
|
|
729
729
|
const t = _catchall.def.type;
|
|
730
|
-
for (const key
|
|
730
|
+
for (const key in input) {
|
|
731
731
|
if (keySet.has(key))
|
|
732
732
|
continue;
|
|
733
733
|
if (t === "never") {
|
package/v4/locales/he.cjs
CHANGED
|
@@ -26,111 +26,222 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.default = default_1;
|
|
27
27
|
const util = __importStar(require("../core/util.cjs"));
|
|
28
28
|
const error = () => {
|
|
29
|
+
// Hebrew labels + grammatical gender
|
|
30
|
+
const TypeNames = {
|
|
31
|
+
string: { label: "מחרוזת", gender: "f" },
|
|
32
|
+
number: { label: "מספר", gender: "m" },
|
|
33
|
+
boolean: { label: "ערך בוליאני", gender: "m" },
|
|
34
|
+
bigint: { label: "BigInt", gender: "m" },
|
|
35
|
+
date: { label: "תאריך", gender: "m" },
|
|
36
|
+
array: { label: "מערך", gender: "m" },
|
|
37
|
+
object: { label: "אובייקט", gender: "m" },
|
|
38
|
+
null: { label: "ערך ריק (null)", gender: "m" },
|
|
39
|
+
undefined: { label: "ערך לא מוגדר (undefined)", gender: "m" },
|
|
40
|
+
symbol: { label: "סימבול (Symbol)", gender: "m" },
|
|
41
|
+
function: { label: "פונקציה", gender: "f" },
|
|
42
|
+
map: { label: "מפה (Map)", gender: "f" },
|
|
43
|
+
set: { label: "קבוצה (Set)", gender: "f" },
|
|
44
|
+
file: { label: "קובץ", gender: "m" },
|
|
45
|
+
promise: { label: "Promise", gender: "m" },
|
|
46
|
+
NaN: { label: "NaN", gender: "m" },
|
|
47
|
+
unknown: { label: "ערך לא ידוע", gender: "m" },
|
|
48
|
+
value: { label: "ערך", gender: "m" },
|
|
49
|
+
};
|
|
50
|
+
// Sizing units for size-related messages + localized origin labels
|
|
29
51
|
const Sizable = {
|
|
30
|
-
string: { unit: "
|
|
31
|
-
file: { unit: "בייטים",
|
|
32
|
-
array: { unit: "פריטים",
|
|
33
|
-
set: { unit: "פריטים",
|
|
52
|
+
string: { unit: "תווים", shortLabel: "קצר", longLabel: "ארוך" },
|
|
53
|
+
file: { unit: "בייטים", shortLabel: "קטן", longLabel: "גדול" },
|
|
54
|
+
array: { unit: "פריטים", shortLabel: "קטן", longLabel: "גדול" },
|
|
55
|
+
set: { unit: "פריטים", shortLabel: "קטן", longLabel: "גדול" },
|
|
56
|
+
number: { unit: "", shortLabel: "קטן", longLabel: "גדול" }, // no unit
|
|
57
|
+
};
|
|
58
|
+
// Helpers — labels, articles, and verbs
|
|
59
|
+
const typeEntry = (t) => (t ? TypeNames[t] : undefined);
|
|
60
|
+
const typeLabel = (t) => {
|
|
61
|
+
const e = typeEntry(t);
|
|
62
|
+
if (e)
|
|
63
|
+
return e.label;
|
|
64
|
+
// fallback: show raw string if unknown
|
|
65
|
+
return t ?? TypeNames.unknown.label;
|
|
34
66
|
};
|
|
35
|
-
|
|
67
|
+
const withDefinite = (t) => `ה${typeLabel(t)}`;
|
|
68
|
+
const verbFor = (t) => {
|
|
69
|
+
const e = typeEntry(t);
|
|
70
|
+
const gender = e?.gender ?? "m";
|
|
71
|
+
return gender === "f" ? "צריכה להיות" : "צריך להיות";
|
|
72
|
+
};
|
|
73
|
+
const getSizing = (origin) => {
|
|
74
|
+
if (!origin)
|
|
75
|
+
return null;
|
|
36
76
|
return Sizable[origin] ?? null;
|
|
37
|
-
}
|
|
77
|
+
};
|
|
78
|
+
// Robust type parser for "received" — returns a key we understand or a constructor name
|
|
38
79
|
const parsedType = (data) => {
|
|
39
80
|
const t = typeof data;
|
|
40
81
|
switch (t) {
|
|
41
|
-
case "number":
|
|
82
|
+
case "number":
|
|
42
83
|
return Number.isNaN(data) ? "NaN" : "number";
|
|
43
|
-
}
|
|
44
84
|
case "object": {
|
|
45
|
-
if (Array.isArray(data))
|
|
85
|
+
if (Array.isArray(data))
|
|
46
86
|
return "array";
|
|
47
|
-
|
|
48
|
-
if (data === null) {
|
|
87
|
+
if (data === null)
|
|
49
88
|
return "null";
|
|
50
|
-
}
|
|
51
89
|
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
52
|
-
return data.constructor.name;
|
|
90
|
+
return data.constructor.name; // keep as-is (e.g., "Date")
|
|
53
91
|
}
|
|
92
|
+
return "object";
|
|
54
93
|
}
|
|
94
|
+
default:
|
|
95
|
+
return t;
|
|
55
96
|
}
|
|
56
|
-
return t;
|
|
57
97
|
};
|
|
58
98
|
const Nouns = {
|
|
59
|
-
regex: "קלט",
|
|
60
|
-
email: "כתובת אימייל",
|
|
61
|
-
url: "כתובת רשת",
|
|
62
|
-
emoji: "אימוג'י",
|
|
63
|
-
uuid: "UUID",
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
99
|
+
regex: { label: "קלט", gender: "m" },
|
|
100
|
+
email: { label: "כתובת אימייל", gender: "f" },
|
|
101
|
+
url: { label: "כתובת רשת", gender: "f" },
|
|
102
|
+
emoji: { label: "אימוג'י", gender: "m" },
|
|
103
|
+
uuid: { label: "UUID", gender: "m" },
|
|
104
|
+
nanoid: { label: "nanoid", gender: "m" },
|
|
105
|
+
guid: { label: "GUID", gender: "m" },
|
|
106
|
+
cuid: { label: "cuid", gender: "m" },
|
|
107
|
+
cuid2: { label: "cuid2", gender: "m" },
|
|
108
|
+
ulid: { label: "ULID", gender: "m" },
|
|
109
|
+
xid: { label: "XID", gender: "m" },
|
|
110
|
+
ksuid: { label: "KSUID", gender: "m" },
|
|
111
|
+
datetime: { label: "תאריך וזמן ISO", gender: "m" },
|
|
112
|
+
date: { label: "תאריך ISO", gender: "m" },
|
|
113
|
+
time: { label: "זמן ISO", gender: "m" },
|
|
114
|
+
duration: { label: "משך זמן ISO", gender: "m" },
|
|
115
|
+
ipv4: { label: "כתובת IPv4", gender: "f" },
|
|
116
|
+
ipv6: { label: "כתובת IPv6", gender: "f" },
|
|
117
|
+
cidrv4: { label: "טווח IPv4", gender: "m" },
|
|
118
|
+
cidrv6: { label: "טווח IPv6", gender: "m" },
|
|
119
|
+
base64: { label: "מחרוזת בבסיס 64", gender: "f" },
|
|
120
|
+
base64url: { label: "מחרוזת בבסיס 64 לכתובות רשת", gender: "f" },
|
|
121
|
+
json_string: { label: "מחרוזת JSON", gender: "f" },
|
|
122
|
+
e164: { label: "מספר E.164", gender: "m" },
|
|
123
|
+
jwt: { label: "JWT", gender: "m" },
|
|
124
|
+
ends_with: { label: "קלט", gender: "m" },
|
|
125
|
+
includes: { label: "קלט", gender: "m" },
|
|
126
|
+
lowercase: { label: "קלט", gender: "m" },
|
|
127
|
+
starts_with: { label: "קלט", gender: "m" },
|
|
128
|
+
uppercase: { label: "קלט", gender: "m" },
|
|
87
129
|
};
|
|
88
130
|
return (issue) => {
|
|
89
131
|
switch (issue.code) {
|
|
90
|
-
case "invalid_type":
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if
|
|
95
|
-
|
|
96
|
-
|
|
132
|
+
case "invalid_type": {
|
|
133
|
+
// Expected type: show without definite article for clearer Hebrew
|
|
134
|
+
const expectedKey = issue.expected;
|
|
135
|
+
const expected = typeLabel(expectedKey);
|
|
136
|
+
// Received: show localized label if known, otherwise constructor/raw
|
|
137
|
+
const receivedKey = parsedType(issue.input);
|
|
138
|
+
const received = TypeNames[receivedKey]?.label ?? receivedKey;
|
|
139
|
+
return `קלט לא תקין: צריך להיות ${expected}, התקבל ${received}`;
|
|
140
|
+
}
|
|
141
|
+
case "invalid_value": {
|
|
142
|
+
if (issue.values.length === 1) {
|
|
143
|
+
return `ערך לא תקין: הערך חייב להיות ${util.stringifyPrimitive(issue.values[0])}`;
|
|
144
|
+
}
|
|
145
|
+
// Join values with proper Hebrew formatting
|
|
146
|
+
const stringified = issue.values.map((v) => util.stringifyPrimitive(v));
|
|
147
|
+
if (issue.values.length === 2) {
|
|
148
|
+
return `ערך לא תקין: האפשרויות המתאימות הן ${stringified[0]} או ${stringified[1]}`;
|
|
149
|
+
}
|
|
150
|
+
// For 3+ values: "a", "b" או "c"
|
|
151
|
+
const lastValue = stringified[stringified.length - 1];
|
|
152
|
+
const restValues = stringified.slice(0, -1).join(", ");
|
|
153
|
+
return `ערך לא תקין: האפשרויות המתאימות הן ${restValues} או ${lastValue}`;
|
|
154
|
+
}
|
|
97
155
|
case "too_big": {
|
|
98
|
-
const adj = issue.inclusive ? "<=" : "<";
|
|
99
156
|
const sizing = getSizing(issue.origin);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
157
|
+
const subject = withDefinite(issue.origin ?? "value");
|
|
158
|
+
if (issue.origin === "string") {
|
|
159
|
+
// Special handling for strings - more natural Hebrew
|
|
160
|
+
return `${sizing?.longLabel ?? "ארוך"} מדי: ${subject} צריכה להכיל ${issue.maximum.toString()} ${sizing?.unit ?? ""} ${issue.inclusive ? "או פחות" : "לכל היותר"}`.trim();
|
|
161
|
+
}
|
|
162
|
+
if (issue.origin === "number") {
|
|
163
|
+
// Natural Hebrew for numbers
|
|
164
|
+
const comparison = issue.inclusive ? `קטן או שווה ל-${issue.maximum}` : `קטן מ-${issue.maximum}`;
|
|
165
|
+
return `גדול מדי: ${subject} צריך להיות ${comparison}`;
|
|
166
|
+
}
|
|
167
|
+
if (issue.origin === "array" || issue.origin === "set") {
|
|
168
|
+
// Natural Hebrew for arrays and sets
|
|
169
|
+
const verb = issue.origin === "set" ? "צריכה" : "צריך";
|
|
170
|
+
const comparison = issue.inclusive
|
|
171
|
+
? `${issue.maximum} ${sizing?.unit ?? ""} או פחות`
|
|
172
|
+
: `פחות מ-${issue.maximum} ${sizing?.unit ?? ""}`;
|
|
173
|
+
return `גדול מדי: ${subject} ${verb} להכיל ${comparison}`.trim();
|
|
174
|
+
}
|
|
175
|
+
const adj = issue.inclusive ? "<=" : "<";
|
|
176
|
+
const be = verbFor(issue.origin ?? "value");
|
|
177
|
+
if (sizing?.unit) {
|
|
178
|
+
return `${sizing.longLabel} מדי: ${subject} ${be} ${adj}${issue.maximum.toString()} ${sizing.unit}`;
|
|
179
|
+
}
|
|
180
|
+
return `${sizing?.longLabel ?? "גדול"} מדי: ${subject} ${be} ${adj}${issue.maximum.toString()}`;
|
|
103
181
|
}
|
|
104
182
|
case "too_small": {
|
|
105
|
-
const adj = issue.inclusive ? ">=" : ">";
|
|
106
183
|
const sizing = getSizing(issue.origin);
|
|
107
|
-
|
|
108
|
-
|
|
184
|
+
const subject = withDefinite(issue.origin ?? "value");
|
|
185
|
+
if (issue.origin === "string") {
|
|
186
|
+
// Special handling for strings - more natural Hebrew
|
|
187
|
+
return `${sizing?.shortLabel ?? "קצר"} מדי: ${subject} צריכה להכיל ${issue.minimum.toString()} ${sizing?.unit ?? ""} ${issue.inclusive ? "או יותר" : "לפחות"}`.trim();
|
|
109
188
|
}
|
|
110
|
-
|
|
189
|
+
if (issue.origin === "number") {
|
|
190
|
+
// Natural Hebrew for numbers
|
|
191
|
+
const comparison = issue.inclusive ? `גדול או שווה ל-${issue.minimum}` : `גדול מ-${issue.minimum}`;
|
|
192
|
+
return `קטן מדי: ${subject} צריך להיות ${comparison}`;
|
|
193
|
+
}
|
|
194
|
+
if (issue.origin === "array" || issue.origin === "set") {
|
|
195
|
+
// Natural Hebrew for arrays and sets
|
|
196
|
+
const verb = issue.origin === "set" ? "צריכה" : "צריך";
|
|
197
|
+
// Special case for singular (minimum === 1)
|
|
198
|
+
if (issue.minimum === 1 && issue.inclusive) {
|
|
199
|
+
const singularPhrase = issue.origin === "set" ? "לפחות פריט אחד" : "לפחות פריט אחד";
|
|
200
|
+
return `קטן מדי: ${subject} ${verb} להכיל ${singularPhrase}`;
|
|
201
|
+
}
|
|
202
|
+
const comparison = issue.inclusive
|
|
203
|
+
? `${issue.minimum} ${sizing?.unit ?? ""} או יותר`
|
|
204
|
+
: `יותר מ-${issue.minimum} ${sizing?.unit ?? ""}`;
|
|
205
|
+
return `קטן מדי: ${subject} ${verb} להכיל ${comparison}`.trim();
|
|
206
|
+
}
|
|
207
|
+
const adj = issue.inclusive ? ">=" : ">";
|
|
208
|
+
const be = verbFor(issue.origin ?? "value");
|
|
209
|
+
if (sizing?.unit) {
|
|
210
|
+
return `${sizing.shortLabel} מדי: ${subject} ${be} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
211
|
+
}
|
|
212
|
+
return `${sizing?.shortLabel ?? "קטן"} מדי: ${subject} ${be} ${adj}${issue.minimum.toString()}`;
|
|
111
213
|
}
|
|
112
214
|
case "invalid_format": {
|
|
113
215
|
const _issue = issue;
|
|
216
|
+
// These apply to strings — use feminine grammar + ה׳ הידיעה
|
|
114
217
|
if (_issue.format === "starts_with")
|
|
115
|
-
return
|
|
218
|
+
return `המחרוזת חייבת להתחיל ב "${_issue.prefix}"`;
|
|
116
219
|
if (_issue.format === "ends_with")
|
|
117
|
-
return
|
|
220
|
+
return `המחרוזת חייבת להסתיים ב "${_issue.suffix}"`;
|
|
118
221
|
if (_issue.format === "includes")
|
|
119
|
-
return
|
|
222
|
+
return `המחרוזת חייבת לכלול "${_issue.includes}"`;
|
|
120
223
|
if (_issue.format === "regex")
|
|
121
|
-
return
|
|
122
|
-
|
|
224
|
+
return `המחרוזת חייבת להתאים לתבנית ${_issue.pattern}`;
|
|
225
|
+
// Handle gender agreement for formats
|
|
226
|
+
const nounEntry = Nouns[_issue.format];
|
|
227
|
+
const noun = nounEntry?.label ?? _issue.format;
|
|
228
|
+
const gender = nounEntry?.gender ?? "m";
|
|
229
|
+
const adjective = gender === "f" ? "תקינה" : "תקין";
|
|
230
|
+
return `${noun} לא ${adjective}`;
|
|
123
231
|
}
|
|
124
232
|
case "not_multiple_of":
|
|
125
233
|
return `מספר לא תקין: חייב להיות מכפלה של ${issue.divisor}`;
|
|
126
234
|
case "unrecognized_keys":
|
|
127
235
|
return `מפתח${issue.keys.length > 1 ? "ות" : ""} לא מזוה${issue.keys.length > 1 ? "ים" : "ה"}: ${util.joinValues(issue.keys, ", ")}`;
|
|
128
|
-
case "invalid_key":
|
|
129
|
-
return
|
|
236
|
+
case "invalid_key": {
|
|
237
|
+
return `שדה לא תקין באובייקט`;
|
|
238
|
+
}
|
|
130
239
|
case "invalid_union":
|
|
131
240
|
return "קלט לא תקין";
|
|
132
|
-
case "invalid_element":
|
|
133
|
-
|
|
241
|
+
case "invalid_element": {
|
|
242
|
+
const place = withDefinite(issue.origin ?? "array");
|
|
243
|
+
return `ערך לא תקין ב${place}`;
|
|
244
|
+
}
|
|
134
245
|
default:
|
|
135
246
|
return `קלט לא תקין`;
|
|
136
247
|
}
|