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