zod 4.1.0-canary.20250724T211341 → 4.1.0-canary.20250729T005826
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/v4/classic/tests/discriminated-unions.test.ts +1 -0
- package/src/v4/classic/tests/file.test.ts +5 -1
- package/src/v4/core/errors.ts +1 -0
- package/src/v4/core/schemas.ts +3 -2
- package/src/v4/core/versions.ts +1 -1
- package/src/v4/locales/index.ts +1 -0
- package/src/v4/locales/yo.ts +131 -0
- package/v4/core/errors.d.cts +1 -0
- package/v4/core/errors.d.ts +1 -0
- package/v4/core/schemas.cjs +1 -0
- package/v4/core/schemas.d.cts +2 -2
- package/v4/core/schemas.d.ts +2 -2
- package/v4/core/schemas.js +1 -0
- 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/yo.cjs +141 -0
- package/v4/locales/yo.d.cts +4 -0
- package/v4/locales/yo.d.ts +4 -0
- package/v4/locales/yo.js +115 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod",
|
|
3
|
-
"version": "4.1.0-canary.
|
|
3
|
+
"version": "4.1.0-canary.20250729T005826",
|
|
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",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { File as WebFile } from "@web-std/file";
|
|
2
2
|
|
|
3
|
-
import { afterEach, beforeEach, expect, test } from "vitest";
|
|
3
|
+
import { afterEach, beforeEach, expect, expectTypeOf, test } from "vitest";
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v4";
|
|
6
6
|
|
|
@@ -26,6 +26,10 @@ test("passing validations", () => {
|
|
|
26
26
|
expect(() => mimeCheck.parse(new File([""], "test.txt", { type: "text/csv" }))).toThrow();
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
+
test("types", () => {
|
|
30
|
+
expectTypeOf(z.file().parse(new File([], "test.txt"))).toEqualTypeOf(new File([], "test.txt"));
|
|
31
|
+
});
|
|
32
|
+
|
|
29
33
|
test("failing validations", () => {
|
|
30
34
|
expect(minCheck.safeParse(new File(["1234"], "test.txt"))).toMatchInlineSnapshot(`
|
|
31
35
|
{
|
package/src/v4/core/errors.ts
CHANGED
|
@@ -67,6 +67,7 @@ export interface $ZodIssueInvalidUnion extends $ZodIssueBase {
|
|
|
67
67
|
readonly code: "invalid_union";
|
|
68
68
|
readonly errors: $ZodIssue[][];
|
|
69
69
|
readonly input: unknown;
|
|
70
|
+
readonly discriminator?: string | undefined;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
export interface $ZodIssueInvalidKey<Input = unknown> extends $ZodIssueBase {
|
package/src/v4/core/schemas.ts
CHANGED
|
@@ -2069,6 +2069,7 @@ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
|
|
|
2069
2069
|
code: "invalid_union",
|
|
2070
2070
|
errors: [],
|
|
2071
2071
|
note: "No matching discriminator",
|
|
2072
|
+
discriminator: def.discriminator,
|
|
2072
2073
|
input,
|
|
2073
2074
|
path: [def.discriminator],
|
|
2074
2075
|
inst,
|
|
@@ -2862,8 +2863,8 @@ export const $ZodLiteral: core.$constructor<$ZodLiteral> = /*@__PURE__*/ core.$c
|
|
|
2862
2863
|
type _File = typeof globalThis extends { File: infer F extends new (...args: any[]) => any } ? InstanceType<F> : {};
|
|
2863
2864
|
/** Do not reference this directly. */
|
|
2864
2865
|
export interface File extends _File {
|
|
2865
|
-
type: string;
|
|
2866
|
-
size: number;
|
|
2866
|
+
readonly type: string;
|
|
2867
|
+
readonly size: number;
|
|
2867
2868
|
}
|
|
2868
2869
|
|
|
2869
2870
|
export interface $ZodFileDef extends $ZodTypeDef {
|
package/src/v4/core/versions.ts
CHANGED
package/src/v4/locales/index.ts
CHANGED
|
@@ -0,0 +1,131 @@
|
|
|
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
|
+
const error: () => errors.$ZodErrorMap = () => {
|
|
6
|
+
const Sizable: Record<string, { unit: string; verb: string }> = {
|
|
7
|
+
string: { unit: "àmi", verb: "ní" },
|
|
8
|
+
file: { unit: "bytes", verb: "ní" },
|
|
9
|
+
array: { unit: "nkan", verb: "ní" },
|
|
10
|
+
set: { unit: "nkan", verb: "ní" },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function getSizing(origin: string): { unit: string; verb: string } | null {
|
|
14
|
+
return Sizable[origin] ?? null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const parsedType = (data: any): string => {
|
|
18
|
+
const t = typeof data;
|
|
19
|
+
|
|
20
|
+
switch (t) {
|
|
21
|
+
case "number": {
|
|
22
|
+
return Number.isNaN(data) ? "NaN" : "nọ́mbà";
|
|
23
|
+
}
|
|
24
|
+
case "object": {
|
|
25
|
+
if (Array.isArray(data)) {
|
|
26
|
+
return "akopọ";
|
|
27
|
+
}
|
|
28
|
+
if (data === null) {
|
|
29
|
+
return "null";
|
|
30
|
+
}
|
|
31
|
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
32
|
+
return data.constructor.name;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return t;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const Nouns: {
|
|
40
|
+
[k in $ZodStringFormats | (string & {})]?: string;
|
|
41
|
+
} = {
|
|
42
|
+
regex: "ẹ̀rọ ìbáwọlé",
|
|
43
|
+
email: "àdírẹ́sì ìmẹ́lì",
|
|
44
|
+
url: "URL",
|
|
45
|
+
emoji: "emoji",
|
|
46
|
+
uuid: "UUID",
|
|
47
|
+
uuidv4: "UUIDv4",
|
|
48
|
+
uuidv6: "UUIDv6",
|
|
49
|
+
nanoid: "nanoid",
|
|
50
|
+
guid: "GUID",
|
|
51
|
+
cuid: "cuid",
|
|
52
|
+
cuid2: "cuid2",
|
|
53
|
+
ulid: "ULID",
|
|
54
|
+
xid: "XID",
|
|
55
|
+
ksuid: "KSUID",
|
|
56
|
+
datetime: "àkókò ISO",
|
|
57
|
+
date: "ọjọ́ ISO",
|
|
58
|
+
time: "àkókò ISO",
|
|
59
|
+
duration: "àkókò tó pé ISO",
|
|
60
|
+
ipv4: "àdírẹ́sì IPv4",
|
|
61
|
+
ipv6: "àdírẹ́sì IPv6",
|
|
62
|
+
cidrv4: "àgbègbè IPv4",
|
|
63
|
+
cidrv6: "àgbègbè IPv6",
|
|
64
|
+
base64: "ọ̀rọ̀ tí a kọ́ ní base64",
|
|
65
|
+
base64url: "ọ̀rọ̀ base64url",
|
|
66
|
+
json_string: "ọ̀rọ̀ JSON",
|
|
67
|
+
e164: "nọ́mbà E.164",
|
|
68
|
+
jwt: "JWT",
|
|
69
|
+
template_literal: "ẹ̀rọ ìbáwọlé",
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return (issue) => {
|
|
73
|
+
switch (issue.code) {
|
|
74
|
+
case "invalid_type":
|
|
75
|
+
return `Ìbáwọlé aṣìṣe: a ní láti fi ${issue.expected}, àmọ̀ a rí ${parsedType(issue.input)}`;
|
|
76
|
+
|
|
77
|
+
case "invalid_value":
|
|
78
|
+
if (issue.values.length === 1) return `Ìbáwọlé aṣìṣe: a ní láti fi ${util.stringifyPrimitive(issue.values[0])}`;
|
|
79
|
+
return `Àṣàyàn aṣìṣe: yan ọ̀kan lára ${util.joinValues(issue.values, "|")}`;
|
|
80
|
+
|
|
81
|
+
case "too_big": {
|
|
82
|
+
const adj = issue.inclusive ? "<=" : "<";
|
|
83
|
+
const sizing = getSizing(issue.origin);
|
|
84
|
+
if (sizing)
|
|
85
|
+
return `Tó pọ̀ jù: a ní láti jẹ́ pé ${issue.origin ?? "iye"} ${sizing.verb} ${adj}${issue.maximum} ${sizing.unit}`;
|
|
86
|
+
return `Tó pọ̀ jù: a ní láti jẹ́ ${adj}${issue.maximum}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
case "too_small": {
|
|
90
|
+
const adj = issue.inclusive ? ">=" : ">";
|
|
91
|
+
const sizing = getSizing(issue.origin);
|
|
92
|
+
if (sizing)
|
|
93
|
+
return `Kéré ju: a ní láti jẹ́ pé ${issue.origin} ${sizing.verb} ${adj}${issue.minimum} ${sizing.unit}`;
|
|
94
|
+
return `Kéré ju: a ní láti jẹ́ ${adj}${issue.minimum}`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
case "invalid_format": {
|
|
98
|
+
const _issue = issue as errors.$ZodStringFormatIssues;
|
|
99
|
+
if (_issue.format === "starts_with") return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bẹ̀rẹ̀ pẹ̀lú "${_issue.prefix}"`;
|
|
100
|
+
if (_issue.format === "ends_with") return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ parí pẹ̀lú "${_issue.suffix}"`;
|
|
101
|
+
if (_issue.format === "includes") return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ ní "${_issue.includes}"`;
|
|
102
|
+
if (_issue.format === "regex") return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bá àpẹẹrẹ mu ${_issue.pattern}`;
|
|
103
|
+
return `Aṣìṣe: ${Nouns[_issue.format] ?? issue.format}`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
case "not_multiple_of":
|
|
107
|
+
return `Nọ́mbà aṣìṣe: gbọ́dọ̀ jẹ́ èyà pípín ti ${issue.divisor}`;
|
|
108
|
+
|
|
109
|
+
case "unrecognized_keys":
|
|
110
|
+
return `Bọtìnì àìmọ̀: ${util.joinValues(issue.keys, ", ")}`;
|
|
111
|
+
|
|
112
|
+
case "invalid_key":
|
|
113
|
+
return `Bọtìnì aṣìṣe nínú ${issue.origin}`;
|
|
114
|
+
|
|
115
|
+
case "invalid_union":
|
|
116
|
+
return "Ìbáwọlé aṣìṣe";
|
|
117
|
+
|
|
118
|
+
case "invalid_element":
|
|
119
|
+
return `Iye aṣìṣe nínú ${issue.origin}`;
|
|
120
|
+
|
|
121
|
+
default:
|
|
122
|
+
return "Ìbáwọlé aṣìṣe";
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export default function (): { localeError: errors.$ZodErrorMap } {
|
|
128
|
+
return {
|
|
129
|
+
localeError: error(),
|
|
130
|
+
};
|
|
131
|
+
}
|
package/v4/core/errors.d.cts
CHANGED
|
@@ -52,6 +52,7 @@ export interface $ZodIssueInvalidUnion extends $ZodIssueBase {
|
|
|
52
52
|
readonly code: "invalid_union";
|
|
53
53
|
readonly errors: $ZodIssue[][];
|
|
54
54
|
readonly input: unknown;
|
|
55
|
+
readonly discriminator?: string | undefined;
|
|
55
56
|
}
|
|
56
57
|
export interface $ZodIssueInvalidKey<Input = unknown> extends $ZodIssueBase {
|
|
57
58
|
readonly code: "invalid_key";
|
package/v4/core/errors.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ export interface $ZodIssueInvalidUnion extends $ZodIssueBase {
|
|
|
52
52
|
readonly code: "invalid_union";
|
|
53
53
|
readonly errors: $ZodIssue[][];
|
|
54
54
|
readonly input: unknown;
|
|
55
|
+
readonly discriminator?: string | undefined;
|
|
55
56
|
}
|
|
56
57
|
export interface $ZodIssueInvalidKey<Input = unknown> extends $ZodIssueBase {
|
|
57
58
|
readonly code: "invalid_key";
|
package/v4/core/schemas.cjs
CHANGED
package/v4/core/schemas.d.cts
CHANGED
|
@@ -768,8 +768,8 @@ type _File = typeof globalThis extends {
|
|
|
768
768
|
} ? InstanceType<F> : {};
|
|
769
769
|
/** Do not reference this directly. */
|
|
770
770
|
export interface File extends _File {
|
|
771
|
-
type: string;
|
|
772
|
-
size: number;
|
|
771
|
+
readonly type: string;
|
|
772
|
+
readonly size: number;
|
|
773
773
|
}
|
|
774
774
|
export interface $ZodFileDef extends $ZodTypeDef {
|
|
775
775
|
type: "file";
|
package/v4/core/schemas.d.ts
CHANGED
|
@@ -768,8 +768,8 @@ type _File = typeof globalThis extends {
|
|
|
768
768
|
} ? InstanceType<F> : {};
|
|
769
769
|
/** Do not reference this directly. */
|
|
770
770
|
export interface File extends _File {
|
|
771
|
-
type: string;
|
|
772
|
-
size: number;
|
|
771
|
+
readonly type: string;
|
|
772
|
+
readonly size: number;
|
|
773
773
|
}
|
|
774
774
|
export interface $ZodFileDef extends $ZodTypeDef {
|
|
775
775
|
type: "file";
|
package/v4/core/schemas.js
CHANGED
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.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.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");
|
|
@@ -86,3 +86,5 @@ var zh_CN_js_1 = require("./zh-CN.cjs");
|
|
|
86
86
|
Object.defineProperty(exports, "zhCN", { enumerable: true, get: function () { return __importDefault(zh_CN_js_1).default; } });
|
|
87
87
|
var zh_TW_js_1 = require("./zh-TW.cjs");
|
|
88
88
|
Object.defineProperty(exports, "zhTW", { enumerable: true, get: function () { return __importDefault(zh_TW_js_1).default; } });
|
|
89
|
+
var yo_js_1 = require("./yo.cjs");
|
|
90
|
+
Object.defineProperty(exports, "yo", { enumerable: true, get: function () { return __importDefault(yo_js_1).default; } });
|
package/v4/locales/index.d.cts
CHANGED
package/v4/locales/index.d.ts
CHANGED
package/v4/locales/index.js
CHANGED
|
@@ -0,0 +1,141 @@
|
|
|
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: "àmi", verb: "ní" },
|
|
31
|
+
file: { unit: "bytes", verb: "ní" },
|
|
32
|
+
array: { unit: "nkan", verb: "ní" },
|
|
33
|
+
set: { unit: "nkan", verb: "ní" },
|
|
34
|
+
};
|
|
35
|
+
function getSizing(origin) {
|
|
36
|
+
return Sizable[origin] ?? null;
|
|
37
|
+
}
|
|
38
|
+
const parsedType = (data) => {
|
|
39
|
+
const t = typeof data;
|
|
40
|
+
switch (t) {
|
|
41
|
+
case "number": {
|
|
42
|
+
return Number.isNaN(data) ? "NaN" : "nọ́mbà";
|
|
43
|
+
}
|
|
44
|
+
case "object": {
|
|
45
|
+
if (Array.isArray(data)) {
|
|
46
|
+
return "akopọ";
|
|
47
|
+
}
|
|
48
|
+
if (data === null) {
|
|
49
|
+
return "null";
|
|
50
|
+
}
|
|
51
|
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
52
|
+
return data.constructor.name;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return t;
|
|
57
|
+
};
|
|
58
|
+
const Nouns = {
|
|
59
|
+
regex: "ẹ̀rọ ìbáwọlé",
|
|
60
|
+
email: "àdírẹ́sì ìmẹ́lì",
|
|
61
|
+
url: "URL",
|
|
62
|
+
emoji: "emoji",
|
|
63
|
+
uuid: "UUID",
|
|
64
|
+
uuidv4: "UUIDv4",
|
|
65
|
+
uuidv6: "UUIDv6",
|
|
66
|
+
nanoid: "nanoid",
|
|
67
|
+
guid: "GUID",
|
|
68
|
+
cuid: "cuid",
|
|
69
|
+
cuid2: "cuid2",
|
|
70
|
+
ulid: "ULID",
|
|
71
|
+
xid: "XID",
|
|
72
|
+
ksuid: "KSUID",
|
|
73
|
+
datetime: "àkókò ISO",
|
|
74
|
+
date: "ọjọ́ ISO",
|
|
75
|
+
time: "àkókò ISO",
|
|
76
|
+
duration: "àkókò tó pé ISO",
|
|
77
|
+
ipv4: "àdírẹ́sì IPv4",
|
|
78
|
+
ipv6: "àdírẹ́sì IPv6",
|
|
79
|
+
cidrv4: "àgbègbè IPv4",
|
|
80
|
+
cidrv6: "àgbègbè IPv6",
|
|
81
|
+
base64: "ọ̀rọ̀ tí a kọ́ ní base64",
|
|
82
|
+
base64url: "ọ̀rọ̀ base64url",
|
|
83
|
+
json_string: "ọ̀rọ̀ JSON",
|
|
84
|
+
e164: "nọ́mbà E.164",
|
|
85
|
+
jwt: "JWT",
|
|
86
|
+
template_literal: "ẹ̀rọ ìbáwọlé",
|
|
87
|
+
};
|
|
88
|
+
return (issue) => {
|
|
89
|
+
switch (issue.code) {
|
|
90
|
+
case "invalid_type":
|
|
91
|
+
return `Ìbáwọlé aṣìṣe: a ní láti fi ${issue.expected}, àmọ̀ a rí ${parsedType(issue.input)}`;
|
|
92
|
+
case "invalid_value":
|
|
93
|
+
if (issue.values.length === 1)
|
|
94
|
+
return `Ìbáwọlé aṣìṣe: a ní láti fi ${util.stringifyPrimitive(issue.values[0])}`;
|
|
95
|
+
return `Àṣàyàn aṣìṣe: yan ọ̀kan lára ${util.joinValues(issue.values, "|")}`;
|
|
96
|
+
case "too_big": {
|
|
97
|
+
const adj = issue.inclusive ? "<=" : "<";
|
|
98
|
+
const sizing = getSizing(issue.origin);
|
|
99
|
+
if (sizing)
|
|
100
|
+
return `Tó pọ̀ jù: a ní láti jẹ́ pé ${issue.origin ?? "iye"} ${sizing.verb} ${adj}${issue.maximum} ${sizing.unit}`;
|
|
101
|
+
return `Tó pọ̀ jù: a ní láti jẹ́ ${adj}${issue.maximum}`;
|
|
102
|
+
}
|
|
103
|
+
case "too_small": {
|
|
104
|
+
const adj = issue.inclusive ? ">=" : ">";
|
|
105
|
+
const sizing = getSizing(issue.origin);
|
|
106
|
+
if (sizing)
|
|
107
|
+
return `Kéré ju: a ní láti jẹ́ pé ${issue.origin} ${sizing.verb} ${adj}${issue.minimum} ${sizing.unit}`;
|
|
108
|
+
return `Kéré ju: a ní láti jẹ́ ${adj}${issue.minimum}`;
|
|
109
|
+
}
|
|
110
|
+
case "invalid_format": {
|
|
111
|
+
const _issue = issue;
|
|
112
|
+
if (_issue.format === "starts_with")
|
|
113
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bẹ̀rẹ̀ pẹ̀lú "${_issue.prefix}"`;
|
|
114
|
+
if (_issue.format === "ends_with")
|
|
115
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ parí pẹ̀lú "${_issue.suffix}"`;
|
|
116
|
+
if (_issue.format === "includes")
|
|
117
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ ní "${_issue.includes}"`;
|
|
118
|
+
if (_issue.format === "regex")
|
|
119
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bá àpẹẹrẹ mu ${_issue.pattern}`;
|
|
120
|
+
return `Aṣìṣe: ${Nouns[_issue.format] ?? issue.format}`;
|
|
121
|
+
}
|
|
122
|
+
case "not_multiple_of":
|
|
123
|
+
return `Nọ́mbà aṣìṣe: gbọ́dọ̀ jẹ́ èyà pípín ti ${issue.divisor}`;
|
|
124
|
+
case "unrecognized_keys":
|
|
125
|
+
return `Bọtìnì àìmọ̀: ${util.joinValues(issue.keys, ", ")}`;
|
|
126
|
+
case "invalid_key":
|
|
127
|
+
return `Bọtìnì aṣìṣe nínú ${issue.origin}`;
|
|
128
|
+
case "invalid_union":
|
|
129
|
+
return "Ìbáwọlé aṣìṣe";
|
|
130
|
+
case "invalid_element":
|
|
131
|
+
return `Iye aṣìṣe nínú ${issue.origin}`;
|
|
132
|
+
default:
|
|
133
|
+
return "Ìbáwọlé aṣìṣe";
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
function default_1() {
|
|
138
|
+
return {
|
|
139
|
+
localeError: error(),
|
|
140
|
+
};
|
|
141
|
+
}
|
package/v4/locales/yo.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as util from "../core/util.js";
|
|
2
|
+
const error = () => {
|
|
3
|
+
const Sizable = {
|
|
4
|
+
string: { unit: "àmi", verb: "ní" },
|
|
5
|
+
file: { unit: "bytes", verb: "ní" },
|
|
6
|
+
array: { unit: "nkan", verb: "ní" },
|
|
7
|
+
set: { unit: "nkan", verb: "ní" },
|
|
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" : "nọ́mbà";
|
|
17
|
+
}
|
|
18
|
+
case "object": {
|
|
19
|
+
if (Array.isArray(data)) {
|
|
20
|
+
return "akopọ";
|
|
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: "ẹ̀rọ ìbáwọlé",
|
|
34
|
+
email: "àdírẹ́sì ìmẹ́lì",
|
|
35
|
+
url: "URL",
|
|
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: "àkókò ISO",
|
|
48
|
+
date: "ọjọ́ ISO",
|
|
49
|
+
time: "àkókò ISO",
|
|
50
|
+
duration: "àkókò tó pé ISO",
|
|
51
|
+
ipv4: "àdírẹ́sì IPv4",
|
|
52
|
+
ipv6: "àdírẹ́sì IPv6",
|
|
53
|
+
cidrv4: "àgbègbè IPv4",
|
|
54
|
+
cidrv6: "àgbègbè IPv6",
|
|
55
|
+
base64: "ọ̀rọ̀ tí a kọ́ ní base64",
|
|
56
|
+
base64url: "ọ̀rọ̀ base64url",
|
|
57
|
+
json_string: "ọ̀rọ̀ JSON",
|
|
58
|
+
e164: "nọ́mbà E.164",
|
|
59
|
+
jwt: "JWT",
|
|
60
|
+
template_literal: "ẹ̀rọ ìbáwọlé",
|
|
61
|
+
};
|
|
62
|
+
return (issue) => {
|
|
63
|
+
switch (issue.code) {
|
|
64
|
+
case "invalid_type":
|
|
65
|
+
return `Ìbáwọlé aṣìṣe: a ní láti fi ${issue.expected}, àmọ̀ a rí ${parsedType(issue.input)}`;
|
|
66
|
+
case "invalid_value":
|
|
67
|
+
if (issue.values.length === 1)
|
|
68
|
+
return `Ìbáwọlé aṣìṣe: a ní láti fi ${util.stringifyPrimitive(issue.values[0])}`;
|
|
69
|
+
return `Àṣàyàn aṣìṣe: yan ọ̀kan lára ${util.joinValues(issue.values, "|")}`;
|
|
70
|
+
case "too_big": {
|
|
71
|
+
const adj = issue.inclusive ? "<=" : "<";
|
|
72
|
+
const sizing = getSizing(issue.origin);
|
|
73
|
+
if (sizing)
|
|
74
|
+
return `Tó pọ̀ jù: a ní láti jẹ́ pé ${issue.origin ?? "iye"} ${sizing.verb} ${adj}${issue.maximum} ${sizing.unit}`;
|
|
75
|
+
return `Tó pọ̀ jù: a ní láti jẹ́ ${adj}${issue.maximum}`;
|
|
76
|
+
}
|
|
77
|
+
case "too_small": {
|
|
78
|
+
const adj = issue.inclusive ? ">=" : ">";
|
|
79
|
+
const sizing = getSizing(issue.origin);
|
|
80
|
+
if (sizing)
|
|
81
|
+
return `Kéré ju: a ní láti jẹ́ pé ${issue.origin} ${sizing.verb} ${adj}${issue.minimum} ${sizing.unit}`;
|
|
82
|
+
return `Kéré ju: a ní láti jẹ́ ${adj}${issue.minimum}`;
|
|
83
|
+
}
|
|
84
|
+
case "invalid_format": {
|
|
85
|
+
const _issue = issue;
|
|
86
|
+
if (_issue.format === "starts_with")
|
|
87
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bẹ̀rẹ̀ pẹ̀lú "${_issue.prefix}"`;
|
|
88
|
+
if (_issue.format === "ends_with")
|
|
89
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ parí pẹ̀lú "${_issue.suffix}"`;
|
|
90
|
+
if (_issue.format === "includes")
|
|
91
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ ní "${_issue.includes}"`;
|
|
92
|
+
if (_issue.format === "regex")
|
|
93
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bá àpẹẹrẹ mu ${_issue.pattern}`;
|
|
94
|
+
return `Aṣìṣe: ${Nouns[_issue.format] ?? issue.format}`;
|
|
95
|
+
}
|
|
96
|
+
case "not_multiple_of":
|
|
97
|
+
return `Nọ́mbà aṣìṣe: gbọ́dọ̀ jẹ́ èyà pípín ti ${issue.divisor}`;
|
|
98
|
+
case "unrecognized_keys":
|
|
99
|
+
return `Bọtìnì àìmọ̀: ${util.joinValues(issue.keys, ", ")}`;
|
|
100
|
+
case "invalid_key":
|
|
101
|
+
return `Bọtìnì aṣìṣe nínú ${issue.origin}`;
|
|
102
|
+
case "invalid_union":
|
|
103
|
+
return "Ìbáwọlé aṣìṣe";
|
|
104
|
+
case "invalid_element":
|
|
105
|
+
return `Iye aṣìṣe nínú ${issue.origin}`;
|
|
106
|
+
default:
|
|
107
|
+
return "Ìbáwọlé aṣìṣe";
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export default function () {
|
|
112
|
+
return {
|
|
113
|
+
localeError: error(),
|
|
114
|
+
};
|
|
115
|
+
}
|