zod 4.1.6 → 4.1.7
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 +1 -1
- package/package.json +1 -1
- package/src/v4/classic/tests/default.test.ts +8 -0
- package/src/v4/classic/tests/string.test.ts +3 -0
- package/src/v4/classic/tests/template-literal.test.ts +10 -8
- package/src/v4/classic/tests/to-json-schema.test.ts +2 -2
- package/src/v4/core/regexes.ts +9 -9
- package/src/v4/core/schemas.ts +4 -2
- package/src/v4/core/tests/locales/es.test.ts +181 -0
- package/src/v4/core/util.ts +1 -0
- package/src/v4/core/versions.ts +1 -1
- package/src/v4/locales/es.ts +44 -10
- package/src/v4/locales/index.ts +4 -0
- package/src/v4/locales/ka.ts +138 -0
- package/src/v4/locales/kh.ts +3 -122
- package/src/v4/locales/km.ts +126 -0
- package/src/v4/locales/lt.ts +265 -0
- package/src/v4/locales/ua.ts +3 -122
- package/src/v4/locales/uk.ts +126 -0
- package/v4/core/regexes.cjs +9 -9
- package/v4/core/regexes.js +9 -9
- package/v4/core/schemas.cjs +5 -2
- package/v4/core/schemas.js +5 -2
- package/v4/core/util.cjs +2 -0
- package/v4/core/util.js +2 -0
- package/v4/core/versions.cjs +1 -1
- package/v4/core/versions.js +1 -1
- package/v4/locales/es.cjs +42 -10
- package/v4/locales/es.js +42 -10
- package/v4/locales/index.cjs +9 -1
- package/v4/locales/index.d.cts +4 -0
- package/v4/locales/index.d.ts +4 -0
- package/v4/locales/index.js +4 -0
- package/v4/locales/ka.cjs +153 -0
- package/v4/locales/ka.d.cts +5 -0
- package/v4/locales/ka.d.ts +5 -0
- package/v4/locales/ka.js +125 -0
- package/v4/locales/kh.cjs +5 -137
- package/v4/locales/kh.d.ts +1 -0
- package/v4/locales/kh.js +3 -115
- package/v4/locales/km.cjs +144 -0
- package/v4/locales/km.d.cts +5 -0
- package/v4/locales/km.d.ts +4 -0
- package/v4/locales/km.js +117 -0
- package/v4/locales/lt.cjs +258 -0
- package/v4/locales/lt.d.cts +5 -0
- package/v4/locales/lt.d.ts +5 -0
- package/v4/locales/lt.js +230 -0
- package/v4/locales/ua.cjs +5 -137
- package/v4/locales/ua.d.ts +1 -0
- package/v4/locales/ua.js +3 -115
- package/v4/locales/uk.cjs +144 -0
- package/v4/locales/uk.d.cts +5 -0
- package/v4/locales/uk.d.ts +4 -0
- package/v4/locales/uk.js +117 -0
package/v4/locales/uk.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as util from "../core/util.js";
|
|
2
|
+
const error = () => {
|
|
3
|
+
const Sizable = {
|
|
4
|
+
string: { unit: "символів", verb: "матиме" },
|
|
5
|
+
file: { unit: "байтів", verb: "матиме" },
|
|
6
|
+
array: { unit: "елементів", verb: "матиме" },
|
|
7
|
+
set: { unit: "елементів", verb: "матиме" },
|
|
8
|
+
};
|
|
9
|
+
function getSizing(origin) {
|
|
10
|
+
return Sizable[origin] ?? null;
|
|
11
|
+
}
|
|
12
|
+
const parsedType = (data) => {
|
|
13
|
+
const t = typeof data;
|
|
14
|
+
switch (t) {
|
|
15
|
+
case "number": {
|
|
16
|
+
return Number.isNaN(data) ? "NaN" : "число";
|
|
17
|
+
}
|
|
18
|
+
case "object": {
|
|
19
|
+
if (Array.isArray(data)) {
|
|
20
|
+
return "масив";
|
|
21
|
+
}
|
|
22
|
+
if (data === null) {
|
|
23
|
+
return "null";
|
|
24
|
+
}
|
|
25
|
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
26
|
+
return data.constructor.name;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
};
|
|
32
|
+
const Nouns = {
|
|
33
|
+
regex: "вхідні дані",
|
|
34
|
+
email: "адреса електронної пошти",
|
|
35
|
+
url: "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: "рядок у кодуванні base64",
|
|
56
|
+
base64url: "рядок у кодуванні base64url",
|
|
57
|
+
json_string: "рядок JSON",
|
|
58
|
+
e164: "номер E.164",
|
|
59
|
+
jwt: "JWT",
|
|
60
|
+
template_literal: "вхідні дані",
|
|
61
|
+
};
|
|
62
|
+
return (issue) => {
|
|
63
|
+
switch (issue.code) {
|
|
64
|
+
case "invalid_type":
|
|
65
|
+
return `Неправильні вхідні дані: очікується ${issue.expected}, отримано ${parsedType(issue.input)}`;
|
|
66
|
+
// return `Неправильні вхідні дані: очікується ${issue.expected}, отримано ${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, "|")}`;
|
|
71
|
+
case "too_big": {
|
|
72
|
+
const adj = issue.inclusive ? "<=" : "<";
|
|
73
|
+
const sizing = getSizing(issue.origin);
|
|
74
|
+
if (sizing)
|
|
75
|
+
return `Занадто велике: очікується, що ${issue.origin ?? "значення"} ${sizing.verb} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "елементів"}`;
|
|
76
|
+
return `Занадто велике: очікується, що ${issue.origin ?? "значення"} буде ${adj}${issue.maximum.toString()}`;
|
|
77
|
+
}
|
|
78
|
+
case "too_small": {
|
|
79
|
+
const adj = issue.inclusive ? ">=" : ">";
|
|
80
|
+
const sizing = getSizing(issue.origin);
|
|
81
|
+
if (sizing) {
|
|
82
|
+
return `Занадто мале: очікується, що ${issue.origin} ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
83
|
+
}
|
|
84
|
+
return `Занадто мале: очікується, що ${issue.origin} буде ${adj}${issue.minimum.toString()}`;
|
|
85
|
+
}
|
|
86
|
+
case "invalid_format": {
|
|
87
|
+
const _issue = issue;
|
|
88
|
+
if (_issue.format === "starts_with")
|
|
89
|
+
return `Неправильний рядок: повинен починатися з "${_issue.prefix}"`;
|
|
90
|
+
if (_issue.format === "ends_with")
|
|
91
|
+
return `Неправильний рядок: повинен закінчуватися на "${_issue.suffix}"`;
|
|
92
|
+
if (_issue.format === "includes")
|
|
93
|
+
return `Неправильний рядок: повинен містити "${_issue.includes}"`;
|
|
94
|
+
if (_issue.format === "regex")
|
|
95
|
+
return `Неправильний рядок: повинен відповідати шаблону ${_issue.pattern}`;
|
|
96
|
+
return `Неправильний ${Nouns[_issue.format] ?? issue.format}`;
|
|
97
|
+
}
|
|
98
|
+
case "not_multiple_of":
|
|
99
|
+
return `Неправильне число: повинно бути кратним ${issue.divisor}`;
|
|
100
|
+
case "unrecognized_keys":
|
|
101
|
+
return `Нерозпізнаний ключ${issue.keys.length > 1 ? "і" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
|
102
|
+
case "invalid_key":
|
|
103
|
+
return `Неправильний ключ у ${issue.origin}`;
|
|
104
|
+
case "invalid_union":
|
|
105
|
+
return "Неправильні вхідні дані";
|
|
106
|
+
case "invalid_element":
|
|
107
|
+
return `Неправильне значення у ${issue.origin}`;
|
|
108
|
+
default:
|
|
109
|
+
return `Неправильні вхідні дані`;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export default function () {
|
|
114
|
+
return {
|
|
115
|
+
localeError: error(),
|
|
116
|
+
};
|
|
117
|
+
}
|