zod 4.0.4 → 4.0.6
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/v3/tests/string.test.ts +2 -2
- package/src/v3/types.ts +3 -1
- package/src/v4/classic/compat.ts +2 -39
- package/src/v4/classic/errors.ts +9 -2
- package/src/v4/classic/schemas.ts +11 -9
- package/src/v4/classic/tests/catch.test.ts +4 -5
- package/src/v4/classic/tests/discriminated-unions.test.ts +41 -0
- package/src/v4/classic/tests/error-utils.test.ts +43 -0
- package/src/v4/classic/tests/literal.test.ts +25 -0
- package/src/v4/classic/tests/partial.test.ts +193 -0
- package/src/v4/classic/tests/pickomit.test.ts +5 -5
- package/src/v4/classic/tests/preprocess.test.ts +4 -15
- package/src/v4/classic/tests/record.test.ts +15 -1
- package/src/v4/classic/tests/recursive-types.test.ts +67 -0
- package/src/v4/classic/tests/string.test.ts +81 -4
- package/src/v4/classic/tests/template-literal.test.ts +3 -0
- package/src/v4/classic/tests/to-json-schema.test.ts +1 -0
- package/src/v4/classic/tests/transform.test.ts +110 -0
- package/src/v4/classic/tests/union.test.ts +45 -3
- package/src/v4/core/checks.ts +2 -2
- package/src/v4/core/errors.ts +8 -15
- package/src/v4/core/regexes.ts +1 -1
- package/src/v4/core/registries.ts +3 -2
- package/src/v4/core/schemas.ts +93 -99
- package/src/v4/core/to-json-schema.ts +1 -0
- package/src/v4/core/util.ts +175 -115
- package/src/v4/core/versions.ts +1 -1
- package/src/v4/locales/bg.ts +136 -0
- package/src/v4/locales/da.ts +141 -0
- package/src/v4/locales/index.ts +2 -0
- package/src/v4/locales/is.ts +127 -0
- package/src/v4/mini/schemas.ts +3 -1
- package/v3/types.cjs +2 -0
- package/v3/types.d.cts +4 -1
- package/v3/types.d.ts +4 -1
- package/v3/types.js +2 -0
- package/v4/classic/compat.cjs +1 -37
- package/v4/classic/compat.d.cts +1 -37
- package/v4/classic/compat.d.ts +1 -37
- package/v4/classic/compat.js +1 -37
- package/v4/classic/errors.cjs +9 -2
- package/v4/classic/errors.js +9 -2
- package/v4/classic/schemas.cjs +5 -3
- package/v4/classic/schemas.d.cts +3 -3
- package/v4/classic/schemas.d.ts +3 -3
- package/v4/classic/schemas.js +5 -3
- package/v4/core/checks.d.cts +2 -2
- package/v4/core/checks.d.ts +2 -2
- package/v4/core/errors.cjs +4 -9
- package/v4/core/errors.d.cts +4 -6
- package/v4/core/errors.d.ts +4 -6
- package/v4/core/errors.js +4 -9
- package/v4/core/regexes.cjs +1 -1
- package/v4/core/regexes.d.cts +1 -1
- package/v4/core/regexes.d.ts +1 -1
- package/v4/core/regexes.js +1 -1
- package/v4/core/registries.cjs +2 -1
- package/v4/core/registries.d.cts +1 -1
- package/v4/core/registries.d.ts +1 -1
- package/v4/core/registries.js +2 -1
- package/v4/core/schemas.cjs +49 -88
- package/v4/core/schemas.d.cts +10 -4
- package/v4/core/schemas.d.ts +10 -4
- package/v4/core/schemas.js +49 -88
- package/v4/core/to-json-schema.cjs +1 -0
- package/v4/core/to-json-schema.js +1 -0
- package/v4/core/util.cjs +163 -112
- package/v4/core/util.d.cts +1 -0
- package/v4/core/util.d.ts +1 -0
- package/v4/core/util.js +162 -112
- package/v4/core/versions.cjs +1 -1
- package/v4/core/versions.js +1 -1
- package/v4/locales/bg.cjs +156 -0
- package/v4/locales/bg.d.cts +5 -0
- package/v4/locales/bg.d.ts +5 -0
- package/v4/locales/bg.js +128 -0
- package/v4/locales/da.cjs +157 -0
- package/v4/locales/da.d.cts +4 -0
- package/v4/locales/da.d.ts +4 -0
- package/v4/locales/da.js +131 -0
- package/v4/locales/index.cjs +5 -1
- package/v4/locales/index.d.cts +2 -0
- package/v4/locales/index.d.ts +2 -0
- package/v4/locales/index.js +2 -0
- package/v4/locales/is.cjs +145 -0
- package/v4/locales/is.d.cts +5 -0
- package/v4/locales/is.d.ts +5 -0
- package/v4/locales/is.js +117 -0
- package/v4/mini/schemas.cjs +3 -1
- package/v4/mini/schemas.js +3 -1
|
@@ -0,0 +1,157 @@
|
|
|
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.default = default_1;
|
|
27
|
+
const util = __importStar(require("../core/util.cjs"));
|
|
28
|
+
const error = () => {
|
|
29
|
+
const Sizable = {
|
|
30
|
+
string: { unit: "tegn", verb: "havde" },
|
|
31
|
+
file: { unit: "bytes", verb: "havde" },
|
|
32
|
+
array: { unit: "elementer", verb: "indeholdt" },
|
|
33
|
+
set: { unit: "elementer", verb: "indeholdt" },
|
|
34
|
+
};
|
|
35
|
+
const TypeNames = {
|
|
36
|
+
string: "streng",
|
|
37
|
+
number: "tal",
|
|
38
|
+
boolean: "boolean",
|
|
39
|
+
array: "liste",
|
|
40
|
+
object: "objekt",
|
|
41
|
+
set: "sæt",
|
|
42
|
+
file: "fil",
|
|
43
|
+
};
|
|
44
|
+
function getSizing(origin) {
|
|
45
|
+
return Sizable[origin] ?? null;
|
|
46
|
+
}
|
|
47
|
+
function getTypeName(type) {
|
|
48
|
+
return TypeNames[type] ?? type;
|
|
49
|
+
}
|
|
50
|
+
const parsedType = (data) => {
|
|
51
|
+
const t = typeof data;
|
|
52
|
+
switch (t) {
|
|
53
|
+
case "number": {
|
|
54
|
+
return Number.isNaN(data) ? "NaN" : "tal";
|
|
55
|
+
}
|
|
56
|
+
case "object": {
|
|
57
|
+
if (Array.isArray(data)) {
|
|
58
|
+
return "liste";
|
|
59
|
+
}
|
|
60
|
+
if (data === null) {
|
|
61
|
+
return "null";
|
|
62
|
+
}
|
|
63
|
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
64
|
+
return data.constructor.name;
|
|
65
|
+
}
|
|
66
|
+
return "objekt";
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return t;
|
|
70
|
+
};
|
|
71
|
+
const Nouns = {
|
|
72
|
+
regex: "input",
|
|
73
|
+
email: "e-mailadresse",
|
|
74
|
+
url: "URL",
|
|
75
|
+
emoji: "emoji",
|
|
76
|
+
uuid: "UUID",
|
|
77
|
+
uuidv4: "UUIDv4",
|
|
78
|
+
uuidv6: "UUIDv6",
|
|
79
|
+
nanoid: "nanoid",
|
|
80
|
+
guid: "GUID",
|
|
81
|
+
cuid: "cuid",
|
|
82
|
+
cuid2: "cuid2",
|
|
83
|
+
ulid: "ULID",
|
|
84
|
+
xid: "XID",
|
|
85
|
+
ksuid: "KSUID",
|
|
86
|
+
datetime: "ISO dato- og klokkeslæt",
|
|
87
|
+
date: "ISO-dato",
|
|
88
|
+
time: "ISO-klokkeslæt",
|
|
89
|
+
duration: "ISO-varighed",
|
|
90
|
+
ipv4: "IPv4-område",
|
|
91
|
+
ipv6: "IPv6-område",
|
|
92
|
+
cidrv4: "IPv4-spektrum",
|
|
93
|
+
cidrv6: "IPv6-spektrum",
|
|
94
|
+
base64: "base64-kodet streng",
|
|
95
|
+
base64url: "base64url-kodet streng",
|
|
96
|
+
json_string: "JSON-streng",
|
|
97
|
+
e164: "E.164-nummer",
|
|
98
|
+
jwt: "JWT",
|
|
99
|
+
template_literal: "input",
|
|
100
|
+
};
|
|
101
|
+
return (issue) => {
|
|
102
|
+
switch (issue.code) {
|
|
103
|
+
case "invalid_type":
|
|
104
|
+
return `Ugyldigt input: forventede ${getTypeName(issue.expected)}, fik ${getTypeName(parsedType(issue.input))}`;
|
|
105
|
+
case "invalid_value":
|
|
106
|
+
if (issue.values.length === 1)
|
|
107
|
+
return `Ugyldig værdi: forventede ${util.stringifyPrimitive(issue.values[0])}`;
|
|
108
|
+
return `Ugyldigt valg: forventede en af følgende ${util.joinValues(issue.values, "|")}`;
|
|
109
|
+
case "too_big": {
|
|
110
|
+
const adj = issue.inclusive ? "<=" : "<";
|
|
111
|
+
const sizing = getSizing(issue.origin);
|
|
112
|
+
const origin = getTypeName(issue.origin);
|
|
113
|
+
if (sizing)
|
|
114
|
+
return `For stor: forventede ${origin ?? "value"} ${sizing.verb} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "elementer"}`;
|
|
115
|
+
return `For stor: forventede ${origin ?? "value"} havde ${adj} ${issue.maximum.toString()}`;
|
|
116
|
+
}
|
|
117
|
+
case "too_small": {
|
|
118
|
+
const adj = issue.inclusive ? ">=" : ">";
|
|
119
|
+
const sizing = getSizing(issue.origin);
|
|
120
|
+
const origin = getTypeName(issue.origin);
|
|
121
|
+
if (sizing) {
|
|
122
|
+
return `For lille: forventede ${origin} ${sizing.verb} ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
|
|
123
|
+
}
|
|
124
|
+
return `For lille: forventede ${origin} havde ${adj} ${issue.minimum.toString()}`;
|
|
125
|
+
}
|
|
126
|
+
case "invalid_format": {
|
|
127
|
+
const _issue = issue;
|
|
128
|
+
if (_issue.format === "starts_with")
|
|
129
|
+
return `Ugyldig streng: skal starte med "${_issue.prefix}"`;
|
|
130
|
+
if (_issue.format === "ends_with")
|
|
131
|
+
return `Ugyldig streng: skal ende med "${_issue.suffix}"`;
|
|
132
|
+
if (_issue.format === "includes")
|
|
133
|
+
return `Ugyldig streng: skal indeholde "${_issue.includes}"`;
|
|
134
|
+
if (_issue.format === "regex")
|
|
135
|
+
return `Ugyldig streng: skal matche mønsteret ${_issue.pattern}`;
|
|
136
|
+
return `Ugyldig ${Nouns[_issue.format] ?? issue.format}`;
|
|
137
|
+
}
|
|
138
|
+
case "not_multiple_of":
|
|
139
|
+
return `Ugyldigt tal: skal være deleligt med ${issue.divisor}`;
|
|
140
|
+
case "unrecognized_keys":
|
|
141
|
+
return `${issue.keys.length > 1 ? "Ukendte nøgler" : "Ukendt nøgle"}: ${util.joinValues(issue.keys, ", ")}`;
|
|
142
|
+
case "invalid_key":
|
|
143
|
+
return `Ugyldig nøgle i ${issue.origin}`;
|
|
144
|
+
case "invalid_union":
|
|
145
|
+
return "Ugyldigt input: matcher ingen af de tilladte typer";
|
|
146
|
+
case "invalid_element":
|
|
147
|
+
return `Ugyldig værdi i ${issue.origin}`;
|
|
148
|
+
default:
|
|
149
|
+
return `Ugyldigt input`;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
function default_1() {
|
|
154
|
+
return {
|
|
155
|
+
localeError: error(),
|
|
156
|
+
};
|
|
157
|
+
}
|
package/v4/locales/da.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import * as util from "../core/util.js";
|
|
2
|
+
const error = () => {
|
|
3
|
+
const Sizable = {
|
|
4
|
+
string: { unit: "tegn", verb: "havde" },
|
|
5
|
+
file: { unit: "bytes", verb: "havde" },
|
|
6
|
+
array: { unit: "elementer", verb: "indeholdt" },
|
|
7
|
+
set: { unit: "elementer", verb: "indeholdt" },
|
|
8
|
+
};
|
|
9
|
+
const TypeNames = {
|
|
10
|
+
string: "streng",
|
|
11
|
+
number: "tal",
|
|
12
|
+
boolean: "boolean",
|
|
13
|
+
array: "liste",
|
|
14
|
+
object: "objekt",
|
|
15
|
+
set: "sæt",
|
|
16
|
+
file: "fil",
|
|
17
|
+
};
|
|
18
|
+
function getSizing(origin) {
|
|
19
|
+
return Sizable[origin] ?? null;
|
|
20
|
+
}
|
|
21
|
+
function getTypeName(type) {
|
|
22
|
+
return TypeNames[type] ?? type;
|
|
23
|
+
}
|
|
24
|
+
const parsedType = (data) => {
|
|
25
|
+
const t = typeof data;
|
|
26
|
+
switch (t) {
|
|
27
|
+
case "number": {
|
|
28
|
+
return Number.isNaN(data) ? "NaN" : "tal";
|
|
29
|
+
}
|
|
30
|
+
case "object": {
|
|
31
|
+
if (Array.isArray(data)) {
|
|
32
|
+
return "liste";
|
|
33
|
+
}
|
|
34
|
+
if (data === null) {
|
|
35
|
+
return "null";
|
|
36
|
+
}
|
|
37
|
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
38
|
+
return data.constructor.name;
|
|
39
|
+
}
|
|
40
|
+
return "objekt";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return t;
|
|
44
|
+
};
|
|
45
|
+
const Nouns = {
|
|
46
|
+
regex: "input",
|
|
47
|
+
email: "e-mailadresse",
|
|
48
|
+
url: "URL",
|
|
49
|
+
emoji: "emoji",
|
|
50
|
+
uuid: "UUID",
|
|
51
|
+
uuidv4: "UUIDv4",
|
|
52
|
+
uuidv6: "UUIDv6",
|
|
53
|
+
nanoid: "nanoid",
|
|
54
|
+
guid: "GUID",
|
|
55
|
+
cuid: "cuid",
|
|
56
|
+
cuid2: "cuid2",
|
|
57
|
+
ulid: "ULID",
|
|
58
|
+
xid: "XID",
|
|
59
|
+
ksuid: "KSUID",
|
|
60
|
+
datetime: "ISO dato- og klokkeslæt",
|
|
61
|
+
date: "ISO-dato",
|
|
62
|
+
time: "ISO-klokkeslæt",
|
|
63
|
+
duration: "ISO-varighed",
|
|
64
|
+
ipv4: "IPv4-område",
|
|
65
|
+
ipv6: "IPv6-område",
|
|
66
|
+
cidrv4: "IPv4-spektrum",
|
|
67
|
+
cidrv6: "IPv6-spektrum",
|
|
68
|
+
base64: "base64-kodet streng",
|
|
69
|
+
base64url: "base64url-kodet streng",
|
|
70
|
+
json_string: "JSON-streng",
|
|
71
|
+
e164: "E.164-nummer",
|
|
72
|
+
jwt: "JWT",
|
|
73
|
+
template_literal: "input",
|
|
74
|
+
};
|
|
75
|
+
return (issue) => {
|
|
76
|
+
switch (issue.code) {
|
|
77
|
+
case "invalid_type":
|
|
78
|
+
return `Ugyldigt input: forventede ${getTypeName(issue.expected)}, fik ${getTypeName(parsedType(issue.input))}`;
|
|
79
|
+
case "invalid_value":
|
|
80
|
+
if (issue.values.length === 1)
|
|
81
|
+
return `Ugyldig værdi: forventede ${util.stringifyPrimitive(issue.values[0])}`;
|
|
82
|
+
return `Ugyldigt valg: forventede en af følgende ${util.joinValues(issue.values, "|")}`;
|
|
83
|
+
case "too_big": {
|
|
84
|
+
const adj = issue.inclusive ? "<=" : "<";
|
|
85
|
+
const sizing = getSizing(issue.origin);
|
|
86
|
+
const origin = getTypeName(issue.origin);
|
|
87
|
+
if (sizing)
|
|
88
|
+
return `For stor: forventede ${origin ?? "value"} ${sizing.verb} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "elementer"}`;
|
|
89
|
+
return `For stor: forventede ${origin ?? "value"} havde ${adj} ${issue.maximum.toString()}`;
|
|
90
|
+
}
|
|
91
|
+
case "too_small": {
|
|
92
|
+
const adj = issue.inclusive ? ">=" : ">";
|
|
93
|
+
const sizing = getSizing(issue.origin);
|
|
94
|
+
const origin = getTypeName(issue.origin);
|
|
95
|
+
if (sizing) {
|
|
96
|
+
return `For lille: forventede ${origin} ${sizing.verb} ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
|
|
97
|
+
}
|
|
98
|
+
return `For lille: forventede ${origin} havde ${adj} ${issue.minimum.toString()}`;
|
|
99
|
+
}
|
|
100
|
+
case "invalid_format": {
|
|
101
|
+
const _issue = issue;
|
|
102
|
+
if (_issue.format === "starts_with")
|
|
103
|
+
return `Ugyldig streng: skal starte med "${_issue.prefix}"`;
|
|
104
|
+
if (_issue.format === "ends_with")
|
|
105
|
+
return `Ugyldig streng: skal ende med "${_issue.suffix}"`;
|
|
106
|
+
if (_issue.format === "includes")
|
|
107
|
+
return `Ugyldig streng: skal indeholde "${_issue.includes}"`;
|
|
108
|
+
if (_issue.format === "regex")
|
|
109
|
+
return `Ugyldig streng: skal matche mønsteret ${_issue.pattern}`;
|
|
110
|
+
return `Ugyldig ${Nouns[_issue.format] ?? issue.format}`;
|
|
111
|
+
}
|
|
112
|
+
case "not_multiple_of":
|
|
113
|
+
return `Ugyldigt tal: skal være deleligt med ${issue.divisor}`;
|
|
114
|
+
case "unrecognized_keys":
|
|
115
|
+
return `${issue.keys.length > 1 ? "Ukendte nøgler" : "Ukendt nøgle"}: ${util.joinValues(issue.keys, ", ")}`;
|
|
116
|
+
case "invalid_key":
|
|
117
|
+
return `Ugyldig nøgle i ${issue.origin}`;
|
|
118
|
+
case "invalid_union":
|
|
119
|
+
return "Ugyldigt input: matcher ingen af de tilladte typer";
|
|
120
|
+
case "invalid_element":
|
|
121
|
+
return `Ugyldig værdi i ${issue.origin}`;
|
|
122
|
+
default:
|
|
123
|
+
return `Ugyldigt input`;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
export default function () {
|
|
128
|
+
return {
|
|
129
|
+
localeError: error(),
|
|
130
|
+
};
|
|
131
|
+
}
|
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.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.id = exports.hu = exports.he = exports.frCA = exports.fr = exports.fi = exports.fa = exports.es = exports.eo = exports.en = exports.de = exports.cs = exports.ca = exports.be = exports.az = exports.ar = void 0;
|
|
6
|
+
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;
|
|
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");
|
|
@@ -14,6 +14,8 @@ var ca_js_1 = require("./ca.cjs");
|
|
|
14
14
|
Object.defineProperty(exports, "ca", { enumerable: true, get: function () { return __importDefault(ca_js_1).default; } });
|
|
15
15
|
var cs_js_1 = require("./cs.cjs");
|
|
16
16
|
Object.defineProperty(exports, "cs", { enumerable: true, get: function () { return __importDefault(cs_js_1).default; } });
|
|
17
|
+
var da_js_1 = require("./da.cjs");
|
|
18
|
+
Object.defineProperty(exports, "da", { enumerable: true, get: function () { return __importDefault(da_js_1).default; } });
|
|
17
19
|
var de_js_1 = require("./de.cjs");
|
|
18
20
|
Object.defineProperty(exports, "de", { enumerable: true, get: function () { return __importDefault(de_js_1).default; } });
|
|
19
21
|
var en_js_1 = require("./en.cjs");
|
|
@@ -36,6 +38,8 @@ var hu_js_1 = require("./hu.cjs");
|
|
|
36
38
|
Object.defineProperty(exports, "hu", { enumerable: true, get: function () { return __importDefault(hu_js_1).default; } });
|
|
37
39
|
var id_js_1 = require("./id.cjs");
|
|
38
40
|
Object.defineProperty(exports, "id", { enumerable: true, get: function () { return __importDefault(id_js_1).default; } });
|
|
41
|
+
var is_js_1 = require("./is.cjs");
|
|
42
|
+
Object.defineProperty(exports, "is", { enumerable: true, get: function () { return __importDefault(is_js_1).default; } });
|
|
39
43
|
var it_js_1 = require("./it.cjs");
|
|
40
44
|
Object.defineProperty(exports, "it", { enumerable: true, get: function () { return __importDefault(it_js_1).default; } });
|
|
41
45
|
var ja_js_1 = require("./ja.cjs");
|
package/v4/locales/index.d.cts
CHANGED
|
@@ -3,6 +3,7 @@ export { default as az } from "./az.cjs";
|
|
|
3
3
|
export { default as be } from "./be.cjs";
|
|
4
4
|
export { default as ca } from "./ca.cjs";
|
|
5
5
|
export { default as cs } from "./cs.cjs";
|
|
6
|
+
export { default as da } from "./da.cjs";
|
|
6
7
|
export { default as de } from "./de.cjs";
|
|
7
8
|
export { default as en } from "./en.cjs";
|
|
8
9
|
export { default as eo } from "./eo.cjs";
|
|
@@ -14,6 +15,7 @@ export { default as frCA } from "./fr-CA.cjs";
|
|
|
14
15
|
export { default as he } from "./he.cjs";
|
|
15
16
|
export { default as hu } from "./hu.cjs";
|
|
16
17
|
export { default as id } from "./id.cjs";
|
|
18
|
+
export { default as is } from "./is.cjs";
|
|
17
19
|
export { default as it } from "./it.cjs";
|
|
18
20
|
export { default as ja } from "./ja.cjs";
|
|
19
21
|
export { default as kh } from "./kh.cjs";
|
package/v4/locales/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { default as az } from "./az.js";
|
|
|
3
3
|
export { default as be } from "./be.js";
|
|
4
4
|
export { default as ca } from "./ca.js";
|
|
5
5
|
export { default as cs } from "./cs.js";
|
|
6
|
+
export { default as da } from "./da.js";
|
|
6
7
|
export { default as de } from "./de.js";
|
|
7
8
|
export { default as en } from "./en.js";
|
|
8
9
|
export { default as eo } from "./eo.js";
|
|
@@ -14,6 +15,7 @@ export { default as frCA } from "./fr-CA.js";
|
|
|
14
15
|
export { default as he } from "./he.js";
|
|
15
16
|
export { default as hu } from "./hu.js";
|
|
16
17
|
export { default as id } from "./id.js";
|
|
18
|
+
export { default as is } from "./is.js";
|
|
17
19
|
export { default as it } from "./it.js";
|
|
18
20
|
export { default as ja } from "./ja.js";
|
|
19
21
|
export { default as kh } from "./kh.js";
|
package/v4/locales/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { default as az } from "./az.js";
|
|
|
3
3
|
export { default as be } from "./be.js";
|
|
4
4
|
export { default as ca } from "./ca.js";
|
|
5
5
|
export { default as cs } from "./cs.js";
|
|
6
|
+
export { default as da } from "./da.js";
|
|
6
7
|
export { default as de } from "./de.js";
|
|
7
8
|
export { default as en } from "./en.js";
|
|
8
9
|
export { default as eo } from "./eo.js";
|
|
@@ -14,6 +15,7 @@ export { default as frCA } from "./fr-CA.js";
|
|
|
14
15
|
export { default as he } from "./he.js";
|
|
15
16
|
export { default as hu } from "./hu.js";
|
|
16
17
|
export { default as id } from "./id.js";
|
|
18
|
+
export { default as is } from "./is.js";
|
|
17
19
|
export { default as it } from "./it.js";
|
|
18
20
|
export { default as ja } from "./ja.js";
|
|
19
21
|
export { default as kh } from "./kh.js";
|
|
@@ -0,0 +1,145 @@
|
|
|
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
|
+
switch (t) {
|
|
32
|
+
case "number": {
|
|
33
|
+
return Number.isNaN(data) ? "NaN" : "númer";
|
|
34
|
+
}
|
|
35
|
+
case "object": {
|
|
36
|
+
if (Array.isArray(data)) {
|
|
37
|
+
return "fylki";
|
|
38
|
+
}
|
|
39
|
+
if (data === null) {
|
|
40
|
+
return "null";
|
|
41
|
+
}
|
|
42
|
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
43
|
+
return data.constructor.name;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return t;
|
|
48
|
+
};
|
|
49
|
+
exports.parsedType = parsedType;
|
|
50
|
+
const error = () => {
|
|
51
|
+
const Sizable = {
|
|
52
|
+
string: { unit: "stafi", verb: "að hafa" },
|
|
53
|
+
file: { unit: "bæti", verb: "að hafa" },
|
|
54
|
+
array: { unit: "hluti", verb: "að hafa" },
|
|
55
|
+
set: { unit: "hluti", verb: "að hafa" },
|
|
56
|
+
};
|
|
57
|
+
function getSizing(origin) {
|
|
58
|
+
return Sizable[origin] ?? null;
|
|
59
|
+
}
|
|
60
|
+
const Nouns = {
|
|
61
|
+
regex: "gildi",
|
|
62
|
+
email: "netfang",
|
|
63
|
+
url: "vefslóð",
|
|
64
|
+
emoji: "emoji",
|
|
65
|
+
uuid: "UUID",
|
|
66
|
+
uuidv4: "UUIDv4",
|
|
67
|
+
uuidv6: "UUIDv6",
|
|
68
|
+
nanoid: "nanoid",
|
|
69
|
+
guid: "GUID",
|
|
70
|
+
cuid: "cuid",
|
|
71
|
+
cuid2: "cuid2",
|
|
72
|
+
ulid: "ULID",
|
|
73
|
+
xid: "XID",
|
|
74
|
+
ksuid: "KSUID",
|
|
75
|
+
datetime: "ISO dagsetning og tími",
|
|
76
|
+
date: "ISO dagsetning",
|
|
77
|
+
time: "ISO tími",
|
|
78
|
+
duration: "ISO tímalengd",
|
|
79
|
+
ipv4: "IPv4 address",
|
|
80
|
+
ipv6: "IPv6 address",
|
|
81
|
+
cidrv4: "IPv4 range",
|
|
82
|
+
cidrv6: "IPv6 range",
|
|
83
|
+
base64: "base64-encoded strengur",
|
|
84
|
+
base64url: "base64url-encoded strengur",
|
|
85
|
+
json_string: "JSON strengur",
|
|
86
|
+
e164: "E.164 tölugildi",
|
|
87
|
+
jwt: "JWT",
|
|
88
|
+
template_literal: "gildi",
|
|
89
|
+
};
|
|
90
|
+
return (issue) => {
|
|
91
|
+
switch (issue.code) {
|
|
92
|
+
case "invalid_type":
|
|
93
|
+
return `Rangt gildi: Þú slóst inn ${(0, exports.parsedType)(issue.input)} þar sem á að vera ${issue.expected}`;
|
|
94
|
+
case "invalid_value":
|
|
95
|
+
if (issue.values.length === 1)
|
|
96
|
+
return `Rangt gildi: gert ráð fyrir ${util.stringifyPrimitive(issue.values[0])}`;
|
|
97
|
+
return `Ógilt val: má vera eitt af eftirfarandi ${util.joinValues(issue.values, "|")}`;
|
|
98
|
+
case "too_big": {
|
|
99
|
+
const adj = issue.inclusive ? "<=" : "<";
|
|
100
|
+
const sizing = getSizing(issue.origin);
|
|
101
|
+
if (sizing)
|
|
102
|
+
return `Of stórt: gert er ráð fyrir að ${issue.origin ?? "gildi"} hafi ${adj}${issue.maximum.toString()} ${sizing.unit ?? "hluti"}`;
|
|
103
|
+
return `Of stórt: gert er ráð fyrir að ${issue.origin ?? "gildi"} sé ${adj}${issue.maximum.toString()}`;
|
|
104
|
+
}
|
|
105
|
+
case "too_small": {
|
|
106
|
+
const adj = issue.inclusive ? ">=" : ">";
|
|
107
|
+
const sizing = getSizing(issue.origin);
|
|
108
|
+
if (sizing) {
|
|
109
|
+
return `Of lítið: gert er ráð fyrir að ${issue.origin} hafi ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
110
|
+
}
|
|
111
|
+
return `Of lítið: gert er ráð fyrir að ${issue.origin} sé ${adj}${issue.minimum.toString()}`;
|
|
112
|
+
}
|
|
113
|
+
case "invalid_format": {
|
|
114
|
+
const _issue = issue;
|
|
115
|
+
if (_issue.format === "starts_with") {
|
|
116
|
+
return `Ógildur strengur: verður að byrja á "${_issue.prefix}"`;
|
|
117
|
+
}
|
|
118
|
+
if (_issue.format === "ends_with")
|
|
119
|
+
return `Ógildur strengur: verður að enda á "${_issue.suffix}"`;
|
|
120
|
+
if (_issue.format === "includes")
|
|
121
|
+
return `Ógildur strengur: verður að innihalda "${_issue.includes}"`;
|
|
122
|
+
if (_issue.format === "regex")
|
|
123
|
+
return `Ógildur strengur: verður að fylgja mynstri ${_issue.pattern}`;
|
|
124
|
+
return `Rangt ${Nouns[_issue.format] ?? issue.format}`;
|
|
125
|
+
}
|
|
126
|
+
case "not_multiple_of":
|
|
127
|
+
return `Röng tala: verður að vera margfeldi af ${issue.divisor}`;
|
|
128
|
+
case "unrecognized_keys":
|
|
129
|
+
return `Óþekkt ${issue.keys.length > 1 ? "ir lyklar" : "ur lykill"}: ${util.joinValues(issue.keys, ", ")}`;
|
|
130
|
+
case "invalid_key":
|
|
131
|
+
return `Rangur lykill í ${issue.origin}`;
|
|
132
|
+
case "invalid_union":
|
|
133
|
+
return "Rangt gildi";
|
|
134
|
+
case "invalid_element":
|
|
135
|
+
return `Rangt gildi í ${issue.origin}`;
|
|
136
|
+
default:
|
|
137
|
+
return `Rangt gildi`;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
function default_1() {
|
|
142
|
+
return {
|
|
143
|
+
localeError: error(),
|
|
144
|
+
};
|
|
145
|
+
}
|
package/v4/locales/is.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as util from "../core/util.js";
|
|
2
|
+
export const parsedType = (data) => {
|
|
3
|
+
const t = typeof data;
|
|
4
|
+
switch (t) {
|
|
5
|
+
case "number": {
|
|
6
|
+
return Number.isNaN(data) ? "NaN" : "númer";
|
|
7
|
+
}
|
|
8
|
+
case "object": {
|
|
9
|
+
if (Array.isArray(data)) {
|
|
10
|
+
return "fylki";
|
|
11
|
+
}
|
|
12
|
+
if (data === null) {
|
|
13
|
+
return "null";
|
|
14
|
+
}
|
|
15
|
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
16
|
+
return data.constructor.name;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
const error = () => {
|
|
23
|
+
const Sizable = {
|
|
24
|
+
string: { unit: "stafi", verb: "að hafa" },
|
|
25
|
+
file: { unit: "bæti", verb: "að hafa" },
|
|
26
|
+
array: { unit: "hluti", verb: "að hafa" },
|
|
27
|
+
set: { unit: "hluti", verb: "að hafa" },
|
|
28
|
+
};
|
|
29
|
+
function getSizing(origin) {
|
|
30
|
+
return Sizable[origin] ?? null;
|
|
31
|
+
}
|
|
32
|
+
const Nouns = {
|
|
33
|
+
regex: "gildi",
|
|
34
|
+
email: "netfang",
|
|
35
|
+
url: "vefslóð",
|
|
36
|
+
emoji: "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 dagsetning og tími",
|
|
48
|
+
date: "ISO dagsetning",
|
|
49
|
+
time: "ISO tími",
|
|
50
|
+
duration: "ISO tímalengd",
|
|
51
|
+
ipv4: "IPv4 address",
|
|
52
|
+
ipv6: "IPv6 address",
|
|
53
|
+
cidrv4: "IPv4 range",
|
|
54
|
+
cidrv6: "IPv6 range",
|
|
55
|
+
base64: "base64-encoded strengur",
|
|
56
|
+
base64url: "base64url-encoded strengur",
|
|
57
|
+
json_string: "JSON strengur",
|
|
58
|
+
e164: "E.164 tölugildi",
|
|
59
|
+
jwt: "JWT",
|
|
60
|
+
template_literal: "gildi",
|
|
61
|
+
};
|
|
62
|
+
return (issue) => {
|
|
63
|
+
switch (issue.code) {
|
|
64
|
+
case "invalid_type":
|
|
65
|
+
return `Rangt gildi: Þú slóst inn ${parsedType(issue.input)} þar sem á að vera ${issue.expected}`;
|
|
66
|
+
case "invalid_value":
|
|
67
|
+
if (issue.values.length === 1)
|
|
68
|
+
return `Rangt gildi: gert ráð fyrir ${util.stringifyPrimitive(issue.values[0])}`;
|
|
69
|
+
return `Ógilt val: má vera eitt af eftirfarandi ${util.joinValues(issue.values, "|")}`;
|
|
70
|
+
case "too_big": {
|
|
71
|
+
const adj = issue.inclusive ? "<=" : "<";
|
|
72
|
+
const sizing = getSizing(issue.origin);
|
|
73
|
+
if (sizing)
|
|
74
|
+
return `Of stórt: gert er ráð fyrir að ${issue.origin ?? "gildi"} hafi ${adj}${issue.maximum.toString()} ${sizing.unit ?? "hluti"}`;
|
|
75
|
+
return `Of stórt: gert er ráð fyrir að ${issue.origin ?? "gildi"} sé ${adj}${issue.maximum.toString()}`;
|
|
76
|
+
}
|
|
77
|
+
case "too_small": {
|
|
78
|
+
const adj = issue.inclusive ? ">=" : ">";
|
|
79
|
+
const sizing = getSizing(issue.origin);
|
|
80
|
+
if (sizing) {
|
|
81
|
+
return `Of lítið: gert er ráð fyrir að ${issue.origin} hafi ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
82
|
+
}
|
|
83
|
+
return `Of lítið: gert er ráð fyrir að ${issue.origin} sé ${adj}${issue.minimum.toString()}`;
|
|
84
|
+
}
|
|
85
|
+
case "invalid_format": {
|
|
86
|
+
const _issue = issue;
|
|
87
|
+
if (_issue.format === "starts_with") {
|
|
88
|
+
return `Ógildur strengur: verður að byrja á "${_issue.prefix}"`;
|
|
89
|
+
}
|
|
90
|
+
if (_issue.format === "ends_with")
|
|
91
|
+
return `Ógildur strengur: verður að enda á "${_issue.suffix}"`;
|
|
92
|
+
if (_issue.format === "includes")
|
|
93
|
+
return `Ógildur strengur: verður að innihalda "${_issue.includes}"`;
|
|
94
|
+
if (_issue.format === "regex")
|
|
95
|
+
return `Ógildur strengur: verður að fylgja mynstri ${_issue.pattern}`;
|
|
96
|
+
return `Rangt ${Nouns[_issue.format] ?? issue.format}`;
|
|
97
|
+
}
|
|
98
|
+
case "not_multiple_of":
|
|
99
|
+
return `Röng tala: verður að vera margfeldi af ${issue.divisor}`;
|
|
100
|
+
case "unrecognized_keys":
|
|
101
|
+
return `Óþekkt ${issue.keys.length > 1 ? "ir lyklar" : "ur lykill"}: ${util.joinValues(issue.keys, ", ")}`;
|
|
102
|
+
case "invalid_key":
|
|
103
|
+
return `Rangur lykill í ${issue.origin}`;
|
|
104
|
+
case "invalid_union":
|
|
105
|
+
return "Rangt gildi";
|
|
106
|
+
case "invalid_element":
|
|
107
|
+
return `Rangt gildi í ${issue.origin}`;
|
|
108
|
+
default:
|
|
109
|
+
return `Rangt gildi`;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export default function () {
|
|
114
|
+
return {
|
|
115
|
+
localeError: error(),
|
|
116
|
+
};
|
|
117
|
+
}
|
package/v4/mini/schemas.cjs
CHANGED
|
@@ -562,9 +562,11 @@ function record(keyType, valueType, params) {
|
|
|
562
562
|
});
|
|
563
563
|
}
|
|
564
564
|
function partialRecord(keyType, valueType, params) {
|
|
565
|
+
const k = core.clone(keyType);
|
|
566
|
+
k._zod.values = undefined;
|
|
565
567
|
return new exports.ZodMiniRecord({
|
|
566
568
|
type: "record",
|
|
567
|
-
keyType:
|
|
569
|
+
keyType: k,
|
|
568
570
|
valueType: valueType,
|
|
569
571
|
...index_js_1.util.normalizeParams(params),
|
|
570
572
|
});
|