zod 4.2.0-canary.20250911T000242 → 4.2.0-canary.20250911T044631
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/locales/package.json +6 -0
- package/mini/package.json +6 -0
- package/package.json +4 -3
- package/src/v4/classic/schemas.ts +3 -3
- package/src/v4/classic/tests/codec.test.ts +36 -6
- package/src/v4/classic/tests/string.test.ts +1 -0
- package/src/v4/core/schemas.ts +7 -6
- package/src/v4/core/versions.ts +1 -1
- package/src/v4/locales/index.ts +1 -0
- package/src/v4/locales/lt.ts +265 -0
- package/src/v4/mini/schemas.ts +2 -2
- package/src/v4/mini/tests/codec.test.ts +36 -6
- package/v3/package.json +6 -0
- package/v4/classic/package.json +6 -0
- package/v4/classic/schemas.d.cts +3 -3
- package/v4/classic/schemas.d.ts +3 -3
- package/v4/core/package.json +6 -0
- package/v4/core/schemas.cjs +3 -2
- package/v4/core/schemas.d.cts +4 -4
- package/v4/core/schemas.d.ts +4 -4
- package/v4/core/schemas.js +3 -2
- package/v4/core/versions.cjs +1 -1
- package/v4/core/versions.js +1 -1
- package/v4/locales/index.cjs +3 -1
- package/v4/locales/index.d.cts +1 -0
- package/v4/locales/index.d.ts +1 -0
- package/v4/locales/index.js +1 -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/package.json +6 -0
- package/v4/mini/package.json +6 -0
- package/v4/mini/schemas.d.cts +2 -2
- package/v4/mini/schemas.d.ts +2 -2
- package/v4/package.json +6 -0
- package/v4-mini/package.json +6 -0
package/v4/core/schemas.d.ts
CHANGED
|
@@ -945,9 +945,9 @@ export interface $ZodPipeDef<A extends SomeType = $ZodType, B extends SomeType =
|
|
|
945
945
|
in: A;
|
|
946
946
|
out: B;
|
|
947
947
|
/** Only defined inside $ZodCodec instances. */
|
|
948
|
-
transform?: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => core.input<B
|
|
948
|
+
transform?: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
|
|
949
949
|
/** Only defined inside $ZodCodec instances. */
|
|
950
|
-
reverseTransform?: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => core.output<A
|
|
950
|
+
reverseTransform?: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
|
|
951
951
|
}
|
|
952
952
|
export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<B>, core.input<A>> {
|
|
953
953
|
def: $ZodPipeDef<A, B>;
|
|
@@ -962,8 +962,8 @@ export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $Z
|
|
|
962
962
|
}
|
|
963
963
|
export declare const $ZodPipe: core.$constructor<$ZodPipe>;
|
|
964
964
|
export interface $ZodCodecDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodPipeDef<A, B> {
|
|
965
|
-
transform: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => core.input<B
|
|
966
|
-
reverseTransform: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => core.output<A
|
|
965
|
+
transform: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
|
|
966
|
+
reverseTransform: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
|
|
967
967
|
}
|
|
968
968
|
export interface $ZodCodecInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<B>, core.input<A>> {
|
|
969
969
|
def: $ZodCodecDef<A, B>;
|
package/v4/core/schemas.js
CHANGED
|
@@ -333,9 +333,10 @@ export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, d
|
|
|
333
333
|
def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
|
|
334
334
|
$ZodStringFormat.init(inst, def);
|
|
335
335
|
inst._zod.check = (payload) => {
|
|
336
|
-
const
|
|
336
|
+
const segments = payload.value.split("/");
|
|
337
|
+
const [address, prefix] = segments;
|
|
337
338
|
try {
|
|
338
|
-
if (
|
|
339
|
+
if (segments.length !== 2)
|
|
339
340
|
throw new Error();
|
|
340
341
|
const prefixNum = Number(prefix);
|
|
341
342
|
if (`${prefixNum}` !== prefix)
|
package/v4/core/versions.cjs
CHANGED
package/v4/core/versions.js
CHANGED
package/v4/locales/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.yo = exports.zhTW = exports.zhCN = exports.vi = exports.ur = exports.ua = exports.tr = exports.th = exports.ta = exports.sv = exports.sl = exports.ru = exports.pt = exports.pl = exports.ps = exports.ota = exports.no = exports.nl = exports.ms = exports.mk = exports.ko = exports.kh = exports.ja = exports.it = exports.is = exports.id = exports.hu = exports.he = exports.frCA = exports.fr = exports.fi = exports.fa = exports.es = exports.eo = exports.en = exports.de = exports.da = exports.cs = exports.ca = exports.be = exports.az = exports.ar = void 0;
|
|
6
|
+
exports.yo = exports.zhTW = exports.zhCN = exports.vi = exports.ur = exports.ua = exports.tr = exports.th = exports.ta = exports.sv = exports.sl = exports.ru = exports.pt = exports.pl = exports.ps = exports.ota = exports.no = exports.nl = exports.ms = exports.mk = exports.lt = exports.ko = exports.kh = exports.ja = exports.it = exports.is = exports.id = exports.hu = exports.he = exports.frCA = exports.fr = exports.fi = exports.fa = exports.es = exports.eo = exports.en = exports.de = exports.da = exports.cs = exports.ca = exports.be = exports.az = exports.ar = void 0;
|
|
7
7
|
var ar_js_1 = require("./ar.cjs");
|
|
8
8
|
Object.defineProperty(exports, "ar", { enumerable: true, get: function () { return __importDefault(ar_js_1).default; } });
|
|
9
9
|
var az_js_1 = require("./az.cjs");
|
|
@@ -48,6 +48,8 @@ var kh_js_1 = require("./kh.cjs");
|
|
|
48
48
|
Object.defineProperty(exports, "kh", { enumerable: true, get: function () { return __importDefault(kh_js_1).default; } });
|
|
49
49
|
var ko_js_1 = require("./ko.cjs");
|
|
50
50
|
Object.defineProperty(exports, "ko", { enumerable: true, get: function () { return __importDefault(ko_js_1).default; } });
|
|
51
|
+
var lt_js_1 = require("./lt.cjs");
|
|
52
|
+
Object.defineProperty(exports, "lt", { enumerable: true, get: function () { return __importDefault(lt_js_1).default; } });
|
|
51
53
|
var mk_js_1 = require("./mk.cjs");
|
|
52
54
|
Object.defineProperty(exports, "mk", { enumerable: true, get: function () { return __importDefault(mk_js_1).default; } });
|
|
53
55
|
var ms_js_1 = require("./ms.cjs");
|
package/v4/locales/index.d.cts
CHANGED
|
@@ -20,6 +20,7 @@ export { default as it } from "./it.cjs";
|
|
|
20
20
|
export { default as ja } from "./ja.cjs";
|
|
21
21
|
export { default as kh } from "./kh.cjs";
|
|
22
22
|
export { default as ko } from "./ko.cjs";
|
|
23
|
+
export { default as lt } from "./lt.cjs";
|
|
23
24
|
export { default as mk } from "./mk.cjs";
|
|
24
25
|
export { default as ms } from "./ms.cjs";
|
|
25
26
|
export { default as nl } from "./nl.cjs";
|
package/v4/locales/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { default as it } from "./it.js";
|
|
|
20
20
|
export { default as ja } from "./ja.js";
|
|
21
21
|
export { default as kh } from "./kh.js";
|
|
22
22
|
export { default as ko } from "./ko.js";
|
|
23
|
+
export { default as lt } from "./lt.js";
|
|
23
24
|
export { default as mk } from "./mk.js";
|
|
24
25
|
export { default as ms } from "./ms.js";
|
|
25
26
|
export { default as nl } from "./nl.js";
|
package/v4/locales/index.js
CHANGED
|
@@ -20,6 +20,7 @@ export { default as it } from "./it.js";
|
|
|
20
20
|
export { default as ja } from "./ja.js";
|
|
21
21
|
export { default as kh } from "./kh.js";
|
|
22
22
|
export { default as ko } from "./ko.js";
|
|
23
|
+
export { default as lt } from "./lt.js";
|
|
23
24
|
export { default as mk } from "./mk.js";
|
|
24
25
|
export { default as ms } from "./ms.js";
|
|
25
26
|
export { default as nl } from "./nl.js";
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.parsedType = void 0;
|
|
27
|
+
exports.default = default_1;
|
|
28
|
+
const util = __importStar(require("../core/util.cjs"));
|
|
29
|
+
const parsedType = (data) => {
|
|
30
|
+
const t = typeof data;
|
|
31
|
+
return parsedTypeFromType(t, data);
|
|
32
|
+
};
|
|
33
|
+
exports.parsedType = parsedType;
|
|
34
|
+
const parsedTypeFromType = (t, data = undefined) => {
|
|
35
|
+
switch (t) {
|
|
36
|
+
case "number": {
|
|
37
|
+
return Number.isNaN(data) ? "NaN" : "skaičius";
|
|
38
|
+
}
|
|
39
|
+
case "bigint": {
|
|
40
|
+
return "sveikasis skaičius";
|
|
41
|
+
}
|
|
42
|
+
case "string": {
|
|
43
|
+
return "eilutė";
|
|
44
|
+
}
|
|
45
|
+
case "boolean": {
|
|
46
|
+
return "loginė reikšmė";
|
|
47
|
+
}
|
|
48
|
+
case "undefined":
|
|
49
|
+
case "void": {
|
|
50
|
+
return "neapibrėžta reikšmė";
|
|
51
|
+
}
|
|
52
|
+
case "function": {
|
|
53
|
+
return "funkcija";
|
|
54
|
+
}
|
|
55
|
+
case "symbol": {
|
|
56
|
+
return "simbolis";
|
|
57
|
+
}
|
|
58
|
+
case "object": {
|
|
59
|
+
if (data === undefined)
|
|
60
|
+
return "nežinomas objektas";
|
|
61
|
+
if (data === null)
|
|
62
|
+
return "nulinė reikšmė";
|
|
63
|
+
if (Array.isArray(data))
|
|
64
|
+
return "masyvas";
|
|
65
|
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
66
|
+
return data.constructor.name;
|
|
67
|
+
}
|
|
68
|
+
return "objektas";
|
|
69
|
+
}
|
|
70
|
+
//Zod types below
|
|
71
|
+
case "null": {
|
|
72
|
+
return "nulinė reikšmė";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return t;
|
|
76
|
+
};
|
|
77
|
+
const capitalizeFirstCharacter = (text) => {
|
|
78
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
79
|
+
};
|
|
80
|
+
function getUnitTypeFromNumber(number) {
|
|
81
|
+
const abs = Math.abs(number);
|
|
82
|
+
const last = abs % 10;
|
|
83
|
+
const last2 = abs % 100;
|
|
84
|
+
if ((last2 >= 11 && last2 <= 19) || last === 0)
|
|
85
|
+
return "many";
|
|
86
|
+
if (last === 1)
|
|
87
|
+
return "one";
|
|
88
|
+
return "few";
|
|
89
|
+
}
|
|
90
|
+
const error = () => {
|
|
91
|
+
const Sizable = {
|
|
92
|
+
string: {
|
|
93
|
+
unit: {
|
|
94
|
+
one: "simbolis",
|
|
95
|
+
few: "simboliai",
|
|
96
|
+
many: "simbolių",
|
|
97
|
+
},
|
|
98
|
+
verb: {
|
|
99
|
+
smaller: {
|
|
100
|
+
inclusive: "turi būti ne ilgesnė kaip",
|
|
101
|
+
notInclusive: "turi būti trumpesnė kaip",
|
|
102
|
+
},
|
|
103
|
+
bigger: {
|
|
104
|
+
inclusive: "turi būti ne trumpesnė kaip",
|
|
105
|
+
notInclusive: "turi būti ilgesnė kaip",
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
file: {
|
|
110
|
+
unit: {
|
|
111
|
+
one: "baitas",
|
|
112
|
+
few: "baitai",
|
|
113
|
+
many: "baitų",
|
|
114
|
+
},
|
|
115
|
+
verb: {
|
|
116
|
+
smaller: {
|
|
117
|
+
inclusive: "turi būti ne didesnis kaip",
|
|
118
|
+
notInclusive: "turi būti mažesnis kaip",
|
|
119
|
+
},
|
|
120
|
+
bigger: {
|
|
121
|
+
inclusive: "turi būti ne mažesnis kaip",
|
|
122
|
+
notInclusive: "turi būti didesnis kaip",
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
array: {
|
|
127
|
+
unit: {
|
|
128
|
+
one: "elementą",
|
|
129
|
+
few: "elementus",
|
|
130
|
+
many: "elementų",
|
|
131
|
+
},
|
|
132
|
+
verb: {
|
|
133
|
+
smaller: {
|
|
134
|
+
inclusive: "turi turėti ne daugiau kaip",
|
|
135
|
+
notInclusive: "turi turėti mažiau kaip",
|
|
136
|
+
},
|
|
137
|
+
bigger: {
|
|
138
|
+
inclusive: "turi turėti ne mažiau kaip",
|
|
139
|
+
notInclusive: "turi turėti daugiau kaip",
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
set: {
|
|
144
|
+
unit: {
|
|
145
|
+
one: "elementą",
|
|
146
|
+
few: "elementus",
|
|
147
|
+
many: "elementų",
|
|
148
|
+
},
|
|
149
|
+
verb: {
|
|
150
|
+
smaller: {
|
|
151
|
+
inclusive: "turi turėti ne daugiau kaip",
|
|
152
|
+
notInclusive: "turi turėti mažiau kaip",
|
|
153
|
+
},
|
|
154
|
+
bigger: {
|
|
155
|
+
inclusive: "turi turėti ne mažiau kaip",
|
|
156
|
+
notInclusive: "turi turėti daugiau kaip",
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
function getSizing(origin, unitType, inclusive, targetShouldBe) {
|
|
162
|
+
const result = Sizable[origin] ?? null;
|
|
163
|
+
if (result === null)
|
|
164
|
+
return result;
|
|
165
|
+
return {
|
|
166
|
+
unit: result.unit[unitType],
|
|
167
|
+
verb: result.verb[targetShouldBe][inclusive ? "inclusive" : "notInclusive"],
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
const Nouns = {
|
|
171
|
+
regex: "įvestis",
|
|
172
|
+
email: "el. pašto adresas",
|
|
173
|
+
url: "URL",
|
|
174
|
+
emoji: "jaustukas",
|
|
175
|
+
uuid: "UUID",
|
|
176
|
+
uuidv4: "UUIDv4",
|
|
177
|
+
uuidv6: "UUIDv6",
|
|
178
|
+
nanoid: "nanoid",
|
|
179
|
+
guid: "GUID",
|
|
180
|
+
cuid: "cuid",
|
|
181
|
+
cuid2: "cuid2",
|
|
182
|
+
ulid: "ULID",
|
|
183
|
+
xid: "XID",
|
|
184
|
+
ksuid: "KSUID",
|
|
185
|
+
datetime: "ISO data ir laikas",
|
|
186
|
+
date: "ISO data",
|
|
187
|
+
time: "ISO laikas",
|
|
188
|
+
duration: "ISO trukmė",
|
|
189
|
+
ipv4: "IPv4 adresas",
|
|
190
|
+
ipv6: "IPv6 adresas",
|
|
191
|
+
cidrv4: "IPv4 tinklo prefiksas (CIDR)",
|
|
192
|
+
cidrv6: "IPv6 tinklo prefiksas (CIDR)",
|
|
193
|
+
base64: "base64 užkoduota eilutė",
|
|
194
|
+
base64url: "base64url užkoduota eilutė",
|
|
195
|
+
json_string: "JSON eilutė",
|
|
196
|
+
e164: "E.164 numeris",
|
|
197
|
+
jwt: "JWT",
|
|
198
|
+
template_literal: "įvestis",
|
|
199
|
+
};
|
|
200
|
+
return (issue) => {
|
|
201
|
+
switch (issue.code) {
|
|
202
|
+
case "invalid_type":
|
|
203
|
+
return `Gautas tipas ${(0, exports.parsedType)(issue.input)}, o tikėtasi - ${parsedTypeFromType(issue.expected)}`;
|
|
204
|
+
case "invalid_value":
|
|
205
|
+
if (issue.values.length === 1)
|
|
206
|
+
return `Privalo būti ${util.stringifyPrimitive(issue.values[0])}`;
|
|
207
|
+
return `Privalo būti vienas iš ${util.joinValues(issue.values, "|")} pasirinkimų`;
|
|
208
|
+
case "too_big": {
|
|
209
|
+
const origin = parsedTypeFromType(issue.origin);
|
|
210
|
+
const sizing = getSizing(issue.origin, getUnitTypeFromNumber(Number(issue.maximum)), issue.inclusive ?? false, "smaller");
|
|
211
|
+
if (sizing?.verb)
|
|
212
|
+
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} ${sizing.verb} ${issue.maximum.toString()} ${sizing.unit ?? "elementų"}`;
|
|
213
|
+
const adj = issue.inclusive ? "ne didesnis kaip" : "mažesnis kaip";
|
|
214
|
+
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} turi būti ${adj} ${issue.maximum.toString()} ${sizing?.unit}`;
|
|
215
|
+
}
|
|
216
|
+
case "too_small": {
|
|
217
|
+
const origin = parsedTypeFromType(issue.origin);
|
|
218
|
+
const sizing = getSizing(issue.origin, getUnitTypeFromNumber(Number(issue.minimum)), issue.inclusive ?? false, "bigger");
|
|
219
|
+
if (sizing?.verb)
|
|
220
|
+
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} ${sizing.verb} ${issue.minimum.toString()} ${sizing.unit ?? "elementų"}`;
|
|
221
|
+
const adj = issue.inclusive ? "ne mažesnis kaip" : "didesnis kaip";
|
|
222
|
+
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} turi būti ${adj} ${issue.minimum.toString()} ${sizing?.unit}`;
|
|
223
|
+
}
|
|
224
|
+
case "invalid_format": {
|
|
225
|
+
const _issue = issue;
|
|
226
|
+
if (_issue.format === "starts_with") {
|
|
227
|
+
return `Eilutė privalo prasidėti "${_issue.prefix}"`;
|
|
228
|
+
}
|
|
229
|
+
if (_issue.format === "ends_with")
|
|
230
|
+
return `Eilutė privalo pasibaigti "${_issue.suffix}"`;
|
|
231
|
+
if (_issue.format === "includes")
|
|
232
|
+
return `Eilutė privalo įtraukti "${_issue.includes}"`;
|
|
233
|
+
if (_issue.format === "regex")
|
|
234
|
+
return `Eilutė privalo atitikti ${_issue.pattern}`;
|
|
235
|
+
return `Neteisingas ${Nouns[_issue.format] ?? issue.format}`;
|
|
236
|
+
}
|
|
237
|
+
case "not_multiple_of":
|
|
238
|
+
return `Skaičius privalo būti ${issue.divisor} kartotinis.`;
|
|
239
|
+
case "unrecognized_keys":
|
|
240
|
+
return `Neatpažint${issue.keys.length > 1 ? "i" : "as"} rakt${issue.keys.length > 1 ? "ai" : "as"}: ${util.joinValues(issue.keys, ", ")}`;
|
|
241
|
+
case "invalid_key":
|
|
242
|
+
return "Rastas klaidingas raktas";
|
|
243
|
+
case "invalid_union":
|
|
244
|
+
return "Klaidinga įvestis";
|
|
245
|
+
case "invalid_element": {
|
|
246
|
+
const origin = parsedTypeFromType(issue.origin);
|
|
247
|
+
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} turi klaidingą įvestį`;
|
|
248
|
+
}
|
|
249
|
+
default:
|
|
250
|
+
return "Klaidinga įvestis";
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
function default_1() {
|
|
255
|
+
return {
|
|
256
|
+
localeError: error(),
|
|
257
|
+
};
|
|
258
|
+
}
|
package/v4/locales/lt.js
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import * as util from "../core/util.js";
|
|
2
|
+
export const parsedType = (data) => {
|
|
3
|
+
const t = typeof data;
|
|
4
|
+
return parsedTypeFromType(t, data);
|
|
5
|
+
};
|
|
6
|
+
const parsedTypeFromType = (t, data = undefined) => {
|
|
7
|
+
switch (t) {
|
|
8
|
+
case "number": {
|
|
9
|
+
return Number.isNaN(data) ? "NaN" : "skaičius";
|
|
10
|
+
}
|
|
11
|
+
case "bigint": {
|
|
12
|
+
return "sveikasis skaičius";
|
|
13
|
+
}
|
|
14
|
+
case "string": {
|
|
15
|
+
return "eilutė";
|
|
16
|
+
}
|
|
17
|
+
case "boolean": {
|
|
18
|
+
return "loginė reikšmė";
|
|
19
|
+
}
|
|
20
|
+
case "undefined":
|
|
21
|
+
case "void": {
|
|
22
|
+
return "neapibrėžta reikšmė";
|
|
23
|
+
}
|
|
24
|
+
case "function": {
|
|
25
|
+
return "funkcija";
|
|
26
|
+
}
|
|
27
|
+
case "symbol": {
|
|
28
|
+
return "simbolis";
|
|
29
|
+
}
|
|
30
|
+
case "object": {
|
|
31
|
+
if (data === undefined)
|
|
32
|
+
return "nežinomas objektas";
|
|
33
|
+
if (data === null)
|
|
34
|
+
return "nulinė reikšmė";
|
|
35
|
+
if (Array.isArray(data))
|
|
36
|
+
return "masyvas";
|
|
37
|
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
38
|
+
return data.constructor.name;
|
|
39
|
+
}
|
|
40
|
+
return "objektas";
|
|
41
|
+
}
|
|
42
|
+
//Zod types below
|
|
43
|
+
case "null": {
|
|
44
|
+
return "nulinė reikšmė";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return t;
|
|
48
|
+
};
|
|
49
|
+
const capitalizeFirstCharacter = (text) => {
|
|
50
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
51
|
+
};
|
|
52
|
+
function getUnitTypeFromNumber(number) {
|
|
53
|
+
const abs = Math.abs(number);
|
|
54
|
+
const last = abs % 10;
|
|
55
|
+
const last2 = abs % 100;
|
|
56
|
+
if ((last2 >= 11 && last2 <= 19) || last === 0)
|
|
57
|
+
return "many";
|
|
58
|
+
if (last === 1)
|
|
59
|
+
return "one";
|
|
60
|
+
return "few";
|
|
61
|
+
}
|
|
62
|
+
const error = () => {
|
|
63
|
+
const Sizable = {
|
|
64
|
+
string: {
|
|
65
|
+
unit: {
|
|
66
|
+
one: "simbolis",
|
|
67
|
+
few: "simboliai",
|
|
68
|
+
many: "simbolių",
|
|
69
|
+
},
|
|
70
|
+
verb: {
|
|
71
|
+
smaller: {
|
|
72
|
+
inclusive: "turi būti ne ilgesnė kaip",
|
|
73
|
+
notInclusive: "turi būti trumpesnė kaip",
|
|
74
|
+
},
|
|
75
|
+
bigger: {
|
|
76
|
+
inclusive: "turi būti ne trumpesnė kaip",
|
|
77
|
+
notInclusive: "turi būti ilgesnė kaip",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
file: {
|
|
82
|
+
unit: {
|
|
83
|
+
one: "baitas",
|
|
84
|
+
few: "baitai",
|
|
85
|
+
many: "baitų",
|
|
86
|
+
},
|
|
87
|
+
verb: {
|
|
88
|
+
smaller: {
|
|
89
|
+
inclusive: "turi būti ne didesnis kaip",
|
|
90
|
+
notInclusive: "turi būti mažesnis kaip",
|
|
91
|
+
},
|
|
92
|
+
bigger: {
|
|
93
|
+
inclusive: "turi būti ne mažesnis kaip",
|
|
94
|
+
notInclusive: "turi būti didesnis kaip",
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
array: {
|
|
99
|
+
unit: {
|
|
100
|
+
one: "elementą",
|
|
101
|
+
few: "elementus",
|
|
102
|
+
many: "elementų",
|
|
103
|
+
},
|
|
104
|
+
verb: {
|
|
105
|
+
smaller: {
|
|
106
|
+
inclusive: "turi turėti ne daugiau kaip",
|
|
107
|
+
notInclusive: "turi turėti mažiau kaip",
|
|
108
|
+
},
|
|
109
|
+
bigger: {
|
|
110
|
+
inclusive: "turi turėti ne mažiau kaip",
|
|
111
|
+
notInclusive: "turi turėti daugiau kaip",
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
set: {
|
|
116
|
+
unit: {
|
|
117
|
+
one: "elementą",
|
|
118
|
+
few: "elementus",
|
|
119
|
+
many: "elementų",
|
|
120
|
+
},
|
|
121
|
+
verb: {
|
|
122
|
+
smaller: {
|
|
123
|
+
inclusive: "turi turėti ne daugiau kaip",
|
|
124
|
+
notInclusive: "turi turėti mažiau kaip",
|
|
125
|
+
},
|
|
126
|
+
bigger: {
|
|
127
|
+
inclusive: "turi turėti ne mažiau kaip",
|
|
128
|
+
notInclusive: "turi turėti daugiau kaip",
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
function getSizing(origin, unitType, inclusive, targetShouldBe) {
|
|
134
|
+
const result = Sizable[origin] ?? null;
|
|
135
|
+
if (result === null)
|
|
136
|
+
return result;
|
|
137
|
+
return {
|
|
138
|
+
unit: result.unit[unitType],
|
|
139
|
+
verb: result.verb[targetShouldBe][inclusive ? "inclusive" : "notInclusive"],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
const Nouns = {
|
|
143
|
+
regex: "įvestis",
|
|
144
|
+
email: "el. pašto adresas",
|
|
145
|
+
url: "URL",
|
|
146
|
+
emoji: "jaustukas",
|
|
147
|
+
uuid: "UUID",
|
|
148
|
+
uuidv4: "UUIDv4",
|
|
149
|
+
uuidv6: "UUIDv6",
|
|
150
|
+
nanoid: "nanoid",
|
|
151
|
+
guid: "GUID",
|
|
152
|
+
cuid: "cuid",
|
|
153
|
+
cuid2: "cuid2",
|
|
154
|
+
ulid: "ULID",
|
|
155
|
+
xid: "XID",
|
|
156
|
+
ksuid: "KSUID",
|
|
157
|
+
datetime: "ISO data ir laikas",
|
|
158
|
+
date: "ISO data",
|
|
159
|
+
time: "ISO laikas",
|
|
160
|
+
duration: "ISO trukmė",
|
|
161
|
+
ipv4: "IPv4 adresas",
|
|
162
|
+
ipv6: "IPv6 adresas",
|
|
163
|
+
cidrv4: "IPv4 tinklo prefiksas (CIDR)",
|
|
164
|
+
cidrv6: "IPv6 tinklo prefiksas (CIDR)",
|
|
165
|
+
base64: "base64 užkoduota eilutė",
|
|
166
|
+
base64url: "base64url užkoduota eilutė",
|
|
167
|
+
json_string: "JSON eilutė",
|
|
168
|
+
e164: "E.164 numeris",
|
|
169
|
+
jwt: "JWT",
|
|
170
|
+
template_literal: "įvestis",
|
|
171
|
+
};
|
|
172
|
+
return (issue) => {
|
|
173
|
+
switch (issue.code) {
|
|
174
|
+
case "invalid_type":
|
|
175
|
+
return `Gautas tipas ${parsedType(issue.input)}, o tikėtasi - ${parsedTypeFromType(issue.expected)}`;
|
|
176
|
+
case "invalid_value":
|
|
177
|
+
if (issue.values.length === 1)
|
|
178
|
+
return `Privalo būti ${util.stringifyPrimitive(issue.values[0])}`;
|
|
179
|
+
return `Privalo būti vienas iš ${util.joinValues(issue.values, "|")} pasirinkimų`;
|
|
180
|
+
case "too_big": {
|
|
181
|
+
const origin = parsedTypeFromType(issue.origin);
|
|
182
|
+
const sizing = getSizing(issue.origin, getUnitTypeFromNumber(Number(issue.maximum)), issue.inclusive ?? false, "smaller");
|
|
183
|
+
if (sizing?.verb)
|
|
184
|
+
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} ${sizing.verb} ${issue.maximum.toString()} ${sizing.unit ?? "elementų"}`;
|
|
185
|
+
const adj = issue.inclusive ? "ne didesnis kaip" : "mažesnis kaip";
|
|
186
|
+
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} turi būti ${adj} ${issue.maximum.toString()} ${sizing?.unit}`;
|
|
187
|
+
}
|
|
188
|
+
case "too_small": {
|
|
189
|
+
const origin = parsedTypeFromType(issue.origin);
|
|
190
|
+
const sizing = getSizing(issue.origin, getUnitTypeFromNumber(Number(issue.minimum)), issue.inclusive ?? false, "bigger");
|
|
191
|
+
if (sizing?.verb)
|
|
192
|
+
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} ${sizing.verb} ${issue.minimum.toString()} ${sizing.unit ?? "elementų"}`;
|
|
193
|
+
const adj = issue.inclusive ? "ne mažesnis kaip" : "didesnis kaip";
|
|
194
|
+
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} turi būti ${adj} ${issue.minimum.toString()} ${sizing?.unit}`;
|
|
195
|
+
}
|
|
196
|
+
case "invalid_format": {
|
|
197
|
+
const _issue = issue;
|
|
198
|
+
if (_issue.format === "starts_with") {
|
|
199
|
+
return `Eilutė privalo prasidėti "${_issue.prefix}"`;
|
|
200
|
+
}
|
|
201
|
+
if (_issue.format === "ends_with")
|
|
202
|
+
return `Eilutė privalo pasibaigti "${_issue.suffix}"`;
|
|
203
|
+
if (_issue.format === "includes")
|
|
204
|
+
return `Eilutė privalo įtraukti "${_issue.includes}"`;
|
|
205
|
+
if (_issue.format === "regex")
|
|
206
|
+
return `Eilutė privalo atitikti ${_issue.pattern}`;
|
|
207
|
+
return `Neteisingas ${Nouns[_issue.format] ?? issue.format}`;
|
|
208
|
+
}
|
|
209
|
+
case "not_multiple_of":
|
|
210
|
+
return `Skaičius privalo būti ${issue.divisor} kartotinis.`;
|
|
211
|
+
case "unrecognized_keys":
|
|
212
|
+
return `Neatpažint${issue.keys.length > 1 ? "i" : "as"} rakt${issue.keys.length > 1 ? "ai" : "as"}: ${util.joinValues(issue.keys, ", ")}`;
|
|
213
|
+
case "invalid_key":
|
|
214
|
+
return "Rastas klaidingas raktas";
|
|
215
|
+
case "invalid_union":
|
|
216
|
+
return "Klaidinga įvestis";
|
|
217
|
+
case "invalid_element": {
|
|
218
|
+
const origin = parsedTypeFromType(issue.origin);
|
|
219
|
+
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} turi klaidingą įvestį`;
|
|
220
|
+
}
|
|
221
|
+
default:
|
|
222
|
+
return "Klaidinga įvestis";
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
export default function () {
|
|
227
|
+
return {
|
|
228
|
+
localeError: error(),
|
|
229
|
+
};
|
|
230
|
+
}
|
package/v4/mini/schemas.d.cts
CHANGED
|
@@ -326,8 +326,8 @@ export interface ZodMiniCodec<A extends SomeType = core.$ZodType, B extends Some
|
|
|
326
326
|
}
|
|
327
327
|
export declare const ZodMiniCodec: core.$constructor<ZodMiniCodec>;
|
|
328
328
|
export declare function codec<const A extends SomeType, B extends core.SomeType = core.$ZodType>(in_: A, out: B, params: {
|
|
329
|
-
decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.input<B
|
|
330
|
-
encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.output<A
|
|
329
|
+
decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.util.MaybeAsync<core.input<B>>;
|
|
330
|
+
encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
|
|
331
331
|
}): ZodMiniCodec<A, B>;
|
|
332
332
|
export interface ZodMiniReadonly<T extends SomeType = core.$ZodType> extends _ZodMiniType<core.$ZodReadonlyInternals<T>> {
|
|
333
333
|
}
|
package/v4/mini/schemas.d.ts
CHANGED
|
@@ -326,8 +326,8 @@ export interface ZodMiniCodec<A extends SomeType = core.$ZodType, B extends Some
|
|
|
326
326
|
}
|
|
327
327
|
export declare const ZodMiniCodec: core.$constructor<ZodMiniCodec>;
|
|
328
328
|
export declare function codec<const A extends SomeType, B extends core.SomeType = core.$ZodType>(in_: A, out: B, params: {
|
|
329
|
-
decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.input<B
|
|
330
|
-
encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.output<A
|
|
329
|
+
decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.util.MaybeAsync<core.input<B>>;
|
|
330
|
+
encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
|
|
331
331
|
}): ZodMiniCodec<A, B>;
|
|
332
332
|
export interface ZodMiniReadonly<T extends SomeType = core.$ZodType> extends _ZodMiniType<core.$ZodReadonlyInternals<T>> {
|
|
333
333
|
}
|
package/v4/package.json
ADDED