zod 4.1.0-canary.20250711T200924 → 4.1.0-canary.20250723T214008

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "4.1.0-canary.20250711T200924",
3
+ "version": "4.1.0-canary.20250723T214008",
4
4
  "type": "module",
5
5
  "author": "Colin McDonnell <zod@colinhacks.com>",
6
6
  "description": "TypeScript-first schema declaration and validation library with static type inference",
@@ -342,8 +342,8 @@ test("uuid", () => {
342
342
  uuid.parse("9491d710-3185-4e06-bea0-6a2f275345e0");
343
343
  uuid.parse("d89e7b01-7598-ed11-9d7a-0022489382fd"); // new sequential id
344
344
  uuid.parse("00000000-0000-0000-0000-000000000000");
345
- uuid.parse("b3ce60f8-e8b9-40f5-1150-172ede56ff74"); // Variant 0 - RFC 4122: Reserved, NCS backward compatibility
346
- uuid.parse("92e76bf9-28b3-4730-cd7f-cb6bc51f8c09"); // Variant 2 - RFC 4122: Reserved, Microsoft Corporation backward compatibility
345
+ uuid.parse("b3ce60f8-e8b9-40f5-1150-172ede56ff74"); // Variant 0 - RFC 9562/4122: Reserved, NCS backward compatibility
346
+ uuid.parse("92e76bf9-28b3-4730-cd7f-cb6bc51f8c09"); // Variant 2 - RFC 9562/4122: Reserved, Microsoft Corporation backward compatibility
347
347
  const result = uuid.safeParse("9491d710-3185-4e06-bea0-6a2f275345e0X");
348
348
  expect(result.success).toEqual(false);
349
349
  if (!result.success) {
@@ -464,8 +464,8 @@ test(`bad uuid`, () => {
464
464
  "9491d710-3185-0e06-bea0-6a2f275345e0",
465
465
  "9491d710-3185-5e06-0ea0-6a2f275345e0",
466
466
  "d89e7b01-7598-ed11-9d7a-0022489382fd", // new sequential id
467
- "b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 4122: Reserved, NCS backward compatibility
468
- "92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 4122: Reserved, Microsoft Corporation backward compatibility
467
+ "b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 9562/4122: Reserved, NCS backward compatibility
468
+ "92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 9562/4122: Reserved, Microsoft Corporation backward compatibility
469
469
  "invalid uuid",
470
470
  "9491d710-3185-4e06-bea0-6a2f275345e0X",
471
471
  "ffffffff-ffff-ffff-ffff-ffffffffffff",
@@ -481,8 +481,8 @@ test("good guid", () => {
481
481
  for (const goodGuid of [
482
482
  "9491d710-3185-4e06-bea0-6a2f275345e0",
483
483
  "d89e7b01-7598-ed11-9d7a-0022489382fd", // new sequential id
484
- "b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 4122: Reserved, NCS backward compatibility
485
- "92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 4122: Reserved, Microsoft Corporation backward compatibility
484
+ "b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 9562/4122: Reserved, NCS backward compatibility
485
+ "92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 9562/4122: Reserved, Microsoft Corporation backward compatibility
486
486
  "00000000-0000-0000-0000-000000000000",
487
487
  "ffffffff-ffff-ffff-ffff-ffffffffffff",
488
488
  ]) {
@@ -16,7 +16,7 @@ export const extendedDuration: RegExp =
16
16
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
17
17
  export const guid: RegExp = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
18
18
 
19
- /** Returns a regex for validating an RFC 4122 UUID.
19
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
20
20
  *
21
21
  * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
22
22
  export const uuid = (version?: number | undefined): RegExp => {
@@ -14,6 +14,7 @@ export { default as frCA } from "./fr-CA.js";
14
14
  export { default as he } from "./he.js";
15
15
  export { default as hu } from "./hu.js";
16
16
  export { default as id } from "./id.js";
17
+ export { default as is } from "./is.js";
17
18
  export { default as it } from "./it.js";
18
19
  export { default as ja } from "./ja.js";
19
20
  export { default as kh } from "./kh.js";
@@ -0,0 +1,127 @@
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ export const parsedType = (data: any): string => {
6
+ const t = typeof data;
7
+
8
+ switch (t) {
9
+ case "number": {
10
+ return Number.isNaN(data) ? "NaN" : "númer";
11
+ }
12
+ case "object": {
13
+ if (Array.isArray(data)) {
14
+ return "fylki";
15
+ }
16
+ if (data === null) {
17
+ return "null";
18
+ }
19
+
20
+ if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
21
+ return data.constructor.name;
22
+ }
23
+ }
24
+ }
25
+ return t;
26
+ };
27
+
28
+ const error: () => errors.$ZodErrorMap = () => {
29
+ const Sizable: Record<string, { unit: string; verb: string }> = {
30
+ string: { unit: "stafi", verb: "að hafa" },
31
+ file: { unit: "bæti", verb: "að hafa" },
32
+ array: { unit: "hluti", verb: "að hafa" },
33
+ set: { unit: "hluti", verb: "að hafa" },
34
+ };
35
+
36
+ function getSizing(origin: string): { unit: string; verb: string } | null {
37
+ return Sizable[origin] ?? null;
38
+ }
39
+
40
+ const Nouns: {
41
+ [k in $ZodStringFormats | (string & {})]?: string;
42
+ } = {
43
+ regex: "gildi",
44
+ email: "netfang",
45
+ url: "vefslóð",
46
+ emoji: "emoji",
47
+ uuid: "UUID",
48
+ uuidv4: "UUIDv4",
49
+ uuidv6: "UUIDv6",
50
+ nanoid: "nanoid",
51
+ guid: "GUID",
52
+ cuid: "cuid",
53
+ cuid2: "cuid2",
54
+ ulid: "ULID",
55
+ xid: "XID",
56
+ ksuid: "KSUID",
57
+ datetime: "ISO dagsetning og tími",
58
+ date: "ISO dagsetning",
59
+ time: "ISO tími",
60
+ duration: "ISO tímalengd",
61
+ ipv4: "IPv4 address",
62
+ ipv6: "IPv6 address",
63
+ cidrv4: "IPv4 range",
64
+ cidrv6: "IPv6 range",
65
+ base64: "base64-encoded strengur",
66
+ base64url: "base64url-encoded strengur",
67
+ json_string: "JSON strengur",
68
+ e164: "E.164 tölugildi",
69
+ jwt: "JWT",
70
+ template_literal: "gildi",
71
+ };
72
+
73
+ return (issue) => {
74
+ switch (issue.code) {
75
+ case "invalid_type":
76
+ return `Rangt gildi: Þú slóst inn ${parsedType(issue.input)} þar sem á að vera ${issue.expected}`;
77
+
78
+ case "invalid_value":
79
+ if (issue.values.length === 1) return `Rangt gildi: gert ráð fyrir ${util.stringifyPrimitive(issue.values[0])}`;
80
+ return `Ógilt val: má vera eitt af eftirfarandi ${util.joinValues(issue.values, "|")}`;
81
+ case "too_big": {
82
+ const adj = issue.inclusive ? "<=" : "<";
83
+ const sizing = getSizing(issue.origin);
84
+ if (sizing)
85
+ return `Of stórt: gert er ráð fyrir að ${issue.origin ?? "gildi"} hafi ${adj}${issue.maximum.toString()} ${sizing.unit ?? "hluti"}`;
86
+ return `Of stórt: gert er ráð fyrir að ${issue.origin ?? "gildi"} sé ${adj}${issue.maximum.toString()}`;
87
+ }
88
+ case "too_small": {
89
+ const adj = issue.inclusive ? ">=" : ">";
90
+ const sizing = getSizing(issue.origin);
91
+ if (sizing) {
92
+ return `Of lítið: gert er ráð fyrir að ${issue.origin} hafi ${adj}${issue.minimum.toString()} ${sizing.unit}`;
93
+ }
94
+
95
+ return `Of lítið: gert er ráð fyrir að ${issue.origin} sé ${adj}${issue.minimum.toString()}`;
96
+ }
97
+ case "invalid_format": {
98
+ const _issue = issue as errors.$ZodStringFormatIssues;
99
+ if (_issue.format === "starts_with") {
100
+ return `Ógildur strengur: verður að byrja á "${_issue.prefix}"`;
101
+ }
102
+ if (_issue.format === "ends_with") return `Ógildur strengur: verður að enda á "${_issue.suffix}"`;
103
+ if (_issue.format === "includes") return `Ógildur strengur: verður að innihalda "${_issue.includes}"`;
104
+ if (_issue.format === "regex") return `Ógildur strengur: verður að fylgja mynstri ${_issue.pattern}`;
105
+ return `Rangt ${Nouns[_issue.format] ?? issue.format}`;
106
+ }
107
+ case "not_multiple_of":
108
+ return `Röng tala: verður að vera margfeldi af ${issue.divisor}`;
109
+ case "unrecognized_keys":
110
+ return `Óþekkt ${issue.keys.length > 1 ? "ir lyklar" : "ur lykill"}: ${util.joinValues(issue.keys, ", ")}`;
111
+ case "invalid_key":
112
+ return `Rangur lykill í ${issue.origin}`;
113
+ case "invalid_union":
114
+ return "Rangt gildi";
115
+ case "invalid_element":
116
+ return `Rangt gildi í ${issue.origin}`;
117
+ default:
118
+ return `Rangt gildi`;
119
+ }
120
+ };
121
+ };
122
+
123
+ export default function (): { localeError: errors.$ZodErrorMap } {
124
+ return {
125
+ localeError: error(),
126
+ };
127
+ }
@@ -16,7 +16,7 @@ exports.duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\
16
16
  exports.extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
17
17
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
18
18
  exports.guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
19
- /** Returns a regex for validating an RFC 4122 UUID.
19
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
20
20
  *
21
21
  * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
22
22
  const uuid = (version) => {
@@ -10,7 +10,7 @@ export declare const duration: RegExp;
10
10
  export declare const extendedDuration: RegExp;
11
11
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
12
12
  export declare const guid: RegExp;
13
- /** Returns a regex for validating an RFC 4122 UUID.
13
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
14
14
  *
15
15
  * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
16
16
  export declare const uuid: (version?: number | undefined) => RegExp;
@@ -10,7 +10,7 @@ export declare const duration: RegExp;
10
10
  export declare const extendedDuration: RegExp;
11
11
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
12
12
  export declare const guid: RegExp;
13
- /** Returns a regex for validating an RFC 4122 UUID.
13
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
14
14
  *
15
15
  * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
16
16
  export declare const uuid: (version?: number | undefined) => RegExp;
@@ -10,7 +10,7 @@ export const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=
10
10
  export const extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
11
11
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
12
12
  export const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
13
- /** Returns a regex for validating an RFC 4122 UUID.
13
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
14
14
  *
15
15
  * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
16
16
  export const uuid = (version) => {
@@ -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.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");
@@ -36,6 +36,8 @@ var hu_js_1 = require("./hu.cjs");
36
36
  Object.defineProperty(exports, "hu", { enumerable: true, get: function () { return __importDefault(hu_js_1).default; } });
37
37
  var id_js_1 = require("./id.cjs");
38
38
  Object.defineProperty(exports, "id", { enumerable: true, get: function () { return __importDefault(id_js_1).default; } });
39
+ var is_js_1 = require("./is.cjs");
40
+ Object.defineProperty(exports, "is", { enumerable: true, get: function () { return __importDefault(is_js_1).default; } });
39
41
  var it_js_1 = require("./it.cjs");
40
42
  Object.defineProperty(exports, "it", { enumerable: true, get: function () { return __importDefault(it_js_1).default; } });
41
43
  var ja_js_1 = require("./ja.cjs");
@@ -14,6 +14,7 @@ export { default as frCA } from "./fr-CA.cjs";
14
14
  export { default as he } from "./he.cjs";
15
15
  export { default as hu } from "./hu.cjs";
16
16
  export { default as id } from "./id.cjs";
17
+ export { default as is } from "./is.cjs";
17
18
  export { default as it } from "./it.cjs";
18
19
  export { default as ja } from "./ja.cjs";
19
20
  export { default as kh } from "./kh.cjs";
@@ -14,6 +14,7 @@ export { default as frCA } from "./fr-CA.js";
14
14
  export { default as he } from "./he.js";
15
15
  export { default as hu } from "./hu.js";
16
16
  export { default as id } from "./id.js";
17
+ export { default as is } from "./is.js";
17
18
  export { default as it } from "./it.js";
18
19
  export { default as ja } from "./ja.js";
19
20
  export { default as kh } from "./kh.js";
@@ -14,6 +14,7 @@ export { default as frCA } from "./fr-CA.js";
14
14
  export { default as he } from "./he.js";
15
15
  export { default as hu } from "./hu.js";
16
16
  export { default as id } from "./id.js";
17
+ export { default as is } from "./is.js";
17
18
  export { default as it } from "./it.js";
18
19
  export { default as ja } from "./ja.js";
19
20
  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
+ }
@@ -0,0 +1,5 @@
1
+ import type * as errors from "../core/errors.cjs";
2
+ export declare const parsedType: (data: any) => string;
3
+ export default function (): {
4
+ localeError: errors.$ZodErrorMap;
5
+ };
@@ -0,0 +1,5 @@
1
+ import type * as errors from "../core/errors.js";
2
+ export declare const parsedType: (data: any) => string;
3
+ export default function (): {
4
+ localeError: errors.$ZodErrorMap;
5
+ };
@@ -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
+ }