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/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: "אותיות", verb: "לכלול" },
5
- file: { unit: "בייטים", verb: "לכלול" },
6
- array: { unit: "פריטים", verb: "לכלול" },
7
- set: { unit: "פריטים", verb: "לכלול" },
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
- function getSizing(origin) {
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
- uuidv4: "UUIDv4",
39
- uuidv6: "UUIDv6",
40
- nanoid: "nanoid",
41
- guid: "GUID",
42
- cuid: "cuid",
43
- cuid2: "cuid2",
44
- ulid: "ULID",
45
- xid: "XID",
46
- ksuid: "KSUID",
47
- datetime: "תאריך וזמן ISO",
48
- date: "תאריך ISO",
49
- time: "זמן ISO",
50
- duration: "משך זמן ISO",
51
- ipv4: "כתובת IPv4",
52
- ipv6: "כתובת IPv6",
53
- cidrv4: "טווח IPv4",
54
- cidrv6: "טווח IPv6",
55
- base64: "מחרוזת בבסיס 64",
56
- base64url: "מחרוזת בבסיס 64 לכתובות רשת",
57
- json_string: "מחרוזת JSON",
58
- e164: "מספר E.164",
59
- jwt: "JWT",
60
- template_literal: "קלט",
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
- return `קלט לא תקין: צריך ${issue.expected}, התקבל ${parsedType(issue.input)}`;
66
- // return `Invalid input: expected ${issue.expected}, received ${util.getParsedType(issue.input)}`;
67
- case "invalid_value":
68
- if (issue.values.length === 1)
69
- return `קלט לא תקין: צריך ${util.stringifyPrimitive(issue.values[0])}`;
70
- return `קלט לא תקין: צריך אחת מהאפשרויות ${util.joinValues(issue.values, "|")}`;
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
- if (sizing)
75
- return `גדול מדי: ${issue.origin ?? "value"} צריך להיות ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
76
- return `גדול מדי: ${issue.origin ?? "value"} צריך להיות ${adj}${issue.maximum.toString()}`;
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
- if (sizing) {
82
- return `קטן מדי: ${issue.origin} צריך להיות ${adj}${issue.minimum.toString()} ${sizing.unit}`;
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
- return `קטן מדי: ${issue.origin} צריך להיות ${adj}${issue.minimum.toString()}`;
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 `מחרוזת לא תקינה: חייבת להתחיל ב"${_issue.prefix}"`;
192
+ return `המחרוזת חייבת להתחיל ב "${_issue.prefix}"`;
90
193
  if (_issue.format === "ends_with")
91
- return `מחרוזת לא תקינה: חייבת להסתיים ב "${_issue.suffix}"`;
194
+ return `המחרוזת חייבת להסתיים ב "${_issue.suffix}"`;
92
195
  if (_issue.format === "includes")
93
- return `מחרוזת לא תקינה: חייבת לכלול "${_issue.includes}"`;
196
+ return `המחרוזת חייבת לכלול "${_issue.includes}"`;
94
197
  if (_issue.format === "regex")
95
- return `מחרוזת לא תקינה: חייבת להתאים לתבנית ${_issue.pattern}`;
96
- return `${Nouns[_issue.format] ?? issue.format} לא תקין`;
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 `מפתח לא תקין ב${issue.origin}`;
210
+ case "invalid_key": {
211
+ return `שדה לא תקין באובייקט`;
212
+ }
104
213
  case "invalid_union":
105
214
  return "קלט לא תקין";
106
- case "invalid_element":
107
- return `ערך לא תקין ב${issue.origin}`;
215
+ case "invalid_element": {
216
+ const place = withDefinite(issue.origin ?? "array");
217
+ return `ערך לא תקין ב${place}`;
218
+ }
108
219
  default:
109
220
  return `קלט לא תקין`;
110
221
  }