@semihbou/zod-i18n-map 0.0.1

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.
@@ -0,0 +1,19 @@
1
+ import * as zod_v4_core from 'zod/v4/core';
2
+ import { $ZodErrorMap } from 'zod/v4/core';
3
+ import { i18n } from 'i18next';
4
+
5
+ type MakeZodI18nMap = (option?: ZodI18nMapOption) => $ZodErrorMap;
6
+ type ZodI18nMapOption = {
7
+ t?: i18n["t"];
8
+ ns?: string | readonly string[];
9
+ handlePath?: HandlePathOption | false;
10
+ };
11
+ type HandlePathOption = {
12
+ context?: string;
13
+ ns?: string | readonly string[];
14
+ keyPrefix?: string;
15
+ };
16
+ declare const makeZodI18nMap: MakeZodI18nMap;
17
+ declare const zodI18nMap: $ZodErrorMap<zod_v4_core.$ZodIssue>;
18
+
19
+ export { type HandlePathOption, type MakeZodI18nMap, type ZodI18nMapOption, makeZodI18nMap, zodI18nMap };
@@ -0,0 +1,19 @@
1
+ import * as zod_v4_core from 'zod/v4/core';
2
+ import { $ZodErrorMap } from 'zod/v4/core';
3
+ import { i18n } from 'i18next';
4
+
5
+ type MakeZodI18nMap = (option?: ZodI18nMapOption) => $ZodErrorMap;
6
+ type ZodI18nMapOption = {
7
+ t?: i18n["t"];
8
+ ns?: string | readonly string[];
9
+ handlePath?: HandlePathOption | false;
10
+ };
11
+ type HandlePathOption = {
12
+ context?: string;
13
+ ns?: string | readonly string[];
14
+ keyPrefix?: string;
15
+ };
16
+ declare const makeZodI18nMap: MakeZodI18nMap;
17
+ declare const zodI18nMap: $ZodErrorMap<zod_v4_core.$ZodIssue>;
18
+
19
+ export { type HandlePathOption, type MakeZodI18nMap, type ZodI18nMapOption, makeZodI18nMap, zodI18nMap };
package/dist/index.js ADDED
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ makeZodI18nMap: () => makeZodI18nMap,
34
+ zodI18nMap: () => zodI18nMap
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+ var import_i18next = __toESM(require("i18next"));
38
+ var jsonStringifyReplacer = (_, value) => {
39
+ if (typeof value === "bigint") {
40
+ return value.toString();
41
+ }
42
+ return value;
43
+ };
44
+ function joinValues(array, separator = " | ") {
45
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
46
+ }
47
+ var isRecord = (value) => {
48
+ if (typeof value !== "object" || value === null) return false;
49
+ for (const key in value) {
50
+ if (!Object.prototype.hasOwnProperty.call(value, key)) return false;
51
+ }
52
+ return true;
53
+ };
54
+ var getKeyAndValues = (param, defaultKey) => {
55
+ if (typeof param === "string") return { key: param, values: {} };
56
+ if (isRecord(param)) {
57
+ const key = "key" in param && typeof param.key === "string" ? param.key : defaultKey;
58
+ const values = "values" in param && isRecord(param.values) ? param.values : {};
59
+ return { key, values };
60
+ }
61
+ return { key: defaultKey, values: {} };
62
+ };
63
+ var defaultNs = "zod";
64
+ var makeZodI18nMap = (option) => (issue) => {
65
+ const { t, ns, handlePath } = {
66
+ t: import_i18next.default.t,
67
+ ns: defaultNs,
68
+ ...option,
69
+ handlePath: option?.handlePath !== false ? {
70
+ context: "with_path",
71
+ ns: option?.ns ?? defaultNs,
72
+ keyPrefix: void 0,
73
+ ...option?.handlePath
74
+ } : null
75
+ };
76
+ let message;
77
+ message = issue.message ?? "Invalid value";
78
+ const path = issue?.path && !!handlePath ? {
79
+ context: handlePath.context,
80
+ path: t(
81
+ [handlePath.keyPrefix, issue.path.join(".")].filter(Boolean).join("."),
82
+ {
83
+ ns: handlePath.ns,
84
+ defaultValue: issue.path.join(".")
85
+ }
86
+ )
87
+ } : {};
88
+ switch (issue.code) {
89
+ case "invalid_type":
90
+ if (issue.expected === "undefined") {
91
+ message = t("errors.invalid_type_received_undefined", {
92
+ ns,
93
+ defaultValue: message,
94
+ ...path
95
+ });
96
+ } else if (issue.expected === "null") {
97
+ message = t("errors.invalid_type_received_null", {
98
+ ns,
99
+ defaultValue: message,
100
+ ...path
101
+ });
102
+ } else {
103
+ message = t("errors.invalid_type", {
104
+ expected: t(`types.${issue.expected}`, {
105
+ defaultValue: issue.expected,
106
+ ns
107
+ }),
108
+ received: t(`types.${issue.received}`, {
109
+ defaultValue: issue.received,
110
+ ns
111
+ }),
112
+ ns,
113
+ defaultValue: message,
114
+ ...path
115
+ });
116
+ }
117
+ break;
118
+ case "invalid_value":
119
+ message = t("errors.invalid_literal", {
120
+ expected: JSON.stringify(issue.expected, jsonStringifyReplacer),
121
+ ns,
122
+ defaultValue: message,
123
+ ...path
124
+ });
125
+ break;
126
+ case "unrecognized_keys":
127
+ message = t("errors.unrecognized_keys", {
128
+ keys: joinValues(issue.keys, ", "),
129
+ count: issue.keys.length,
130
+ ns,
131
+ defaultValue: message,
132
+ ...path
133
+ });
134
+ break;
135
+ case "invalid_union":
136
+ message = t("errors.invalid_union", {
137
+ ns,
138
+ defaultValue: message,
139
+ ...path
140
+ });
141
+ break;
142
+ case "invalid_format":
143
+ if (issue.format === "date") {
144
+ message = t("errors.invalid_date", {
145
+ ns,
146
+ defaultValue: message,
147
+ ...path
148
+ });
149
+ } else if (issue.format === "starts_with") {
150
+ message = t(`errors.invalid_string.startsWith`, {
151
+ startsWith: issue.format,
152
+ ns,
153
+ defaultValue: message,
154
+ ...path
155
+ });
156
+ } else if (issue.format === "ends_with") {
157
+ message = t(`errors.invalid_string.endsWith`, {
158
+ endsWith: issue.format,
159
+ ns,
160
+ defaultValue: message,
161
+ ...path
162
+ });
163
+ } else {
164
+ message = t(`errors.invalid_string.${issue.format}`, {
165
+ validation: t(`validations.${issue.format}`, {
166
+ defaultValue: issue.format,
167
+ ns
168
+ }),
169
+ ns,
170
+ defaultValue: message,
171
+ ...path
172
+ });
173
+ }
174
+ break;
175
+ case "too_small":
176
+ const minimum = issue.origin === "date" ? new Date(Number(issue.minimum)) : issue.minimum;
177
+ message = t(
178
+ `errors.too_small.${issue.origin}.${issue.exact ? "exact" : issue.inclusive ? "inclusive" : "not_inclusive"}`,
179
+ {
180
+ minimum,
181
+ count: typeof minimum === "number" ? minimum : void 0,
182
+ ns,
183
+ defaultValue: message,
184
+ ...path
185
+ }
186
+ );
187
+ break;
188
+ case "too_big":
189
+ const maximum = issue.origin === "date" ? new Date(Number(issue.maximum)) : issue.maximum;
190
+ message = t(
191
+ `errors.too_big.${issue.origin}.${issue.exact ? "exact" : issue.inclusive ? "inclusive" : "not_inclusive"}`,
192
+ {
193
+ maximum,
194
+ count: typeof maximum === "number" ? maximum : void 0,
195
+ ns,
196
+ defaultValue: message,
197
+ ...path
198
+ }
199
+ );
200
+ break;
201
+ case "custom":
202
+ const { key, values } = getKeyAndValues(
203
+ issue.params?.i18n,
204
+ "errors.custom"
205
+ );
206
+ message = t(key, {
207
+ ...values,
208
+ ns,
209
+ defaultValue: message,
210
+ ...path
211
+ });
212
+ break;
213
+ case "not_multiple_of":
214
+ message = t("errors.not_multiple_of", {
215
+ multipleOf: issue.divisor,
216
+ ns,
217
+ defaultValue: message,
218
+ ...path
219
+ });
220
+ break;
221
+ default:
222
+ }
223
+ return { message };
224
+ };
225
+ var zodI18nMap = makeZodI18nMap();
226
+ // Annotate the CommonJS export names for ESM import in node:
227
+ 0 && (module.exports = {
228
+ makeZodI18nMap,
229
+ zodI18nMap
230
+ });
231
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { $ZodErrorMap } from \"zod/v4/core\";\nimport i18next, { i18n } from \"i18next\";\n\nconst jsonStringifyReplacer = (_: string, value: any): any => {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n return value;\n};\n\nfunction joinValues<T extends any[]>(array: T, separator = \" | \"): string {\n return array\n .map((val) => (typeof val === \"string\" ? `'${val}'` : val))\n .join(separator);\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => {\n if (typeof value !== \"object\" || value === null) return false;\n\n for (const key in value) {\n if (!Object.prototype.hasOwnProperty.call(value, key)) return false;\n }\n\n return true;\n};\n\nconst getKeyAndValues = (\n param: unknown,\n defaultKey: string\n): {\n values: Record<string, unknown>;\n key: string;\n} => {\n if (typeof param === \"string\") return { key: param, values: {} };\n\n if (isRecord(param)) {\n const key =\n \"key\" in param && typeof param.key === \"string\" ? param.key : defaultKey;\n const values =\n \"values\" in param && isRecord(param.values) ? param.values : {};\n return { key, values };\n }\n\n return { key: defaultKey, values: {} };\n};\n\nexport type MakeZodI18nMap = (option?: ZodI18nMapOption) => $ZodErrorMap;\n\nexport type ZodI18nMapOption = {\n t?: i18n[\"t\"];\n ns?: string | readonly string[];\n handlePath?: HandlePathOption | false;\n};\n\nexport type HandlePathOption = {\n context?: string;\n ns?: string | readonly string[];\n keyPrefix?: string;\n};\n\nconst defaultNs = \"zod\";\n\nexport const makeZodI18nMap: MakeZodI18nMap = (option) => (issue) => {\n const { t, ns, handlePath } = {\n t: i18next.t,\n ns: defaultNs,\n ...option,\n handlePath:\n option?.handlePath !== false\n ? {\n context: \"with_path\",\n ns: option?.ns ?? defaultNs,\n keyPrefix: undefined,\n ...option?.handlePath,\n }\n : null,\n };\n\n let message: string;\n message = issue.message ?? \"Invalid value\";\n\n const path =\n issue?.path && !!handlePath\n ? {\n context: handlePath.context,\n path: t(\n [handlePath.keyPrefix, issue.path.join(\".\")]\n .filter(Boolean)\n .join(\".\"),\n {\n ns: handlePath.ns,\n defaultValue: issue.path.join(\".\"),\n }\n ),\n }\n : {};\n\n switch (issue.code) {\n case \"invalid_type\":\n if (issue.expected === \"undefined\") {\n message = t(\"errors.invalid_type_received_undefined\", {\n ns,\n defaultValue: message,\n ...path,\n });\n } else if (issue.expected === \"null\") {\n message = t(\"errors.invalid_type_received_null\", {\n ns,\n defaultValue: message,\n ...path,\n });\n } else {\n message = t(\"errors.invalid_type\", {\n expected: t(`types.${issue.expected}`, {\n defaultValue: issue.expected,\n ns,\n }),\n received: t(`types.${issue.received}`, {\n defaultValue: issue.received,\n ns,\n }),\n ns,\n defaultValue: message,\n ...path,\n });\n }\n break;\n case \"invalid_value\":\n message = t(\"errors.invalid_literal\", {\n expected: JSON.stringify(issue.expected, jsonStringifyReplacer),\n ns,\n defaultValue: message,\n ...path,\n });\n break;\n case \"unrecognized_keys\":\n message = t(\"errors.unrecognized_keys\", {\n keys: joinValues(issue.keys, \", \"),\n count: issue.keys.length,\n ns,\n defaultValue: message,\n ...path,\n });\n break;\n case \"invalid_union\":\n message = t(\"errors.invalid_union\", {\n ns,\n defaultValue: message,\n ...path,\n });\n break;\n case \"invalid_format\":\n if (issue.format === \"date\") {\n message = t(\"errors.invalid_date\", {\n ns,\n defaultValue: message,\n ...path,\n });\n } else if (issue.format === \"starts_with\") {\n message = t(`errors.invalid_string.startsWith`, {\n startsWith: issue.format,\n ns,\n defaultValue: message,\n ...path,\n });\n } else if (issue.format === \"ends_with\") {\n message = t(`errors.invalid_string.endsWith`, {\n endsWith: issue.format,\n ns,\n defaultValue: message,\n ...path,\n });\n } else {\n message = t(`errors.invalid_string.${issue.format}`, {\n validation: t(`validations.${issue.format}`, {\n defaultValue: issue.format,\n ns,\n }),\n ns,\n defaultValue: message,\n ...path,\n });\n }\n break;\n case \"too_small\":\n const minimum =\n issue.origin === \"date\"\n ? new Date(Number(issue.minimum))\n : issue.minimum;\n message = t(\n `errors.too_small.${issue.origin}.${\n issue.exact\n ? \"exact\"\n : issue.inclusive\n ? \"inclusive\"\n : \"not_inclusive\"\n }`,\n {\n minimum,\n count: typeof minimum === \"number\" ? minimum : undefined,\n ns,\n defaultValue: message,\n ...path,\n }\n );\n break;\n case \"too_big\":\n const maximum =\n issue.origin === \"date\"\n ? new Date(Number(issue.maximum))\n : issue.maximum;\n message = t(\n `errors.too_big.${issue.origin}.${\n issue.exact\n ? \"exact\"\n : issue.inclusive\n ? \"inclusive\"\n : \"not_inclusive\"\n }`,\n {\n maximum,\n count: typeof maximum === \"number\" ? maximum : undefined,\n ns,\n defaultValue: message,\n ...path,\n }\n );\n break;\n case \"custom\":\n const { key, values } = getKeyAndValues(\n issue.params?.i18n,\n \"errors.custom\"\n );\n\n message = t(key, {\n ...values,\n ns,\n defaultValue: message,\n ...path,\n });\n break;\n case \"not_multiple_of\":\n message = t(\"errors.not_multiple_of\", {\n multipleOf: issue.divisor,\n ns,\n defaultValue: message,\n ...path,\n });\n break;\n default:\n }\n\n return { message };\n};\n\nexport const zodI18nMap = makeZodI18nMap();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAA8B;AAE9B,IAAM,wBAAwB,CAAC,GAAW,UAAoB;AAC5D,MAAI,OA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,YACN,cACA,eACN;AAAA,QACA;AAAA,UACE;AAAA,UACA,OAAO,OAAO,YAAY,WAAW,UAAU;AAAA,UAC/C;AAAA,UACA,cAAc;AAAA,UACd,GAAG;AAAA,QACL;AAAA,MACF;AACA;AAAA,IACF,KAAK;AACH,YAAM,EAAE,KAAK,OAAO,IAAI;AAAA,QACtB,MAAM,QAAQ;AAAA,QACd;AAAA,MACF;AAEA,gBAAU,EAAE,KAAK;AAAA,QACf,GAAG;AAAA,QACH;AAAA,QACA,cAAc;AAAA,QACd,GAAG;AAAA,MACL,CAAC;AACD;AAAA,IACF,KAAK;AACH,gBAAU,EAAE,0BAA0B;AAAA,QACpC,YAAY,MAAM;AAAA,QAClB;AAAA,QACA,cAAc;AAAA,QACd,GAAG;AAAA,MACL,CAAC;AACD;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,QAAQ;AACnB;AAEO,IAAM,aAAa,eAAe;","names":["i18next"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,195 @@
1
+ // src/index.ts
2
+ import i18next from "i18next";
3
+ var jsonStringifyReplacer = (_, value) => {
4
+ if (typeof value === "bigint") {
5
+ return value.toString();
6
+ }
7
+ return value;
8
+ };
9
+ function joinValues(array, separator = " | ") {
10
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
11
+ }
12
+ var isRecord = (value) => {
13
+ if (typeof value !== "object" || value === null) return false;
14
+ for (const key in value) {
15
+ if (!Object.prototype.hasOwnProperty.call(value, key)) return false;
16
+ }
17
+ return true;
18
+ };
19
+ var getKeyAndValues = (param, defaultKey) => {
20
+ if (typeof param === "string") return { key: param, values: {} };
21
+ if (isRecord(param)) {
22
+ const key = "key" in param && typeof param.key === "string" ? param.key : defaultKey;
23
+ const values = "values" in param && isRecord(param.values) ? param.values : {};
24
+ return { key, values };
25
+ }
26
+ return { key: defaultKey, values: {} };
27
+ };
28
+ var defaultNs = "zod";
29
+ var makeZodI18nMap = (option) => (issue) => {
30
+ const { t, ns, handlePath } = {
31
+ t: i18next.t,
32
+ ns: defaultNs,
33
+ ...option,
34
+ handlePath: option?.handlePath !== false ? {
35
+ context: "with_path",
36
+ ns: option?.ns ?? defaultNs,
37
+ keyPrefix: void 0,
38
+ ...option?.handlePath
39
+ } : null
40
+ };
41
+ let message;
42
+ message = issue.message ?? "Invalid value";
43
+ const path = issue?.path && !!handlePath ? {
44
+ context: handlePath.context,
45
+ path: t(
46
+ [handlePath.keyPrefix, issue.path.join(".")].filter(Boolean).join("."),
47
+ {
48
+ ns: handlePath.ns,
49
+ defaultValue: issue.path.join(".")
50
+ }
51
+ )
52
+ } : {};
53
+ switch (issue.code) {
54
+ case "invalid_type":
55
+ if (issue.expected === "undefined") {
56
+ message = t("errors.invalid_type_received_undefined", {
57
+ ns,
58
+ defaultValue: message,
59
+ ...path
60
+ });
61
+ } else if (issue.expected === "null") {
62
+ message = t("errors.invalid_type_received_null", {
63
+ ns,
64
+ defaultValue: message,
65
+ ...path
66
+ });
67
+ } else {
68
+ message = t("errors.invalid_type", {
69
+ expected: t(`types.${issue.expected}`, {
70
+ defaultValue: issue.expected,
71
+ ns
72
+ }),
73
+ received: t(`types.${issue.received}`, {
74
+ defaultValue: issue.received,
75
+ ns
76
+ }),
77
+ ns,
78
+ defaultValue: message,
79
+ ...path
80
+ });
81
+ }
82
+ break;
83
+ case "invalid_value":
84
+ message = t("errors.invalid_literal", {
85
+ expected: JSON.stringify(issue.expected, jsonStringifyReplacer),
86
+ ns,
87
+ defaultValue: message,
88
+ ...path
89
+ });
90
+ break;
91
+ case "unrecognized_keys":
92
+ message = t("errors.unrecognized_keys", {
93
+ keys: joinValues(issue.keys, ", "),
94
+ count: issue.keys.length,
95
+ ns,
96
+ defaultValue: message,
97
+ ...path
98
+ });
99
+ break;
100
+ case "invalid_union":
101
+ message = t("errors.invalid_union", {
102
+ ns,
103
+ defaultValue: message,
104
+ ...path
105
+ });
106
+ break;
107
+ case "invalid_format":
108
+ if (issue.format === "date") {
109
+ message = t("errors.invalid_date", {
110
+ ns,
111
+ defaultValue: message,
112
+ ...path
113
+ });
114
+ } else if (issue.format === "starts_with") {
115
+ message = t(`errors.invalid_string.startsWith`, {
116
+ startsWith: issue.format,
117
+ ns,
118
+ defaultValue: message,
119
+ ...path
120
+ });
121
+ } else if (issue.format === "ends_with") {
122
+ message = t(`errors.invalid_string.endsWith`, {
123
+ endsWith: issue.format,
124
+ ns,
125
+ defaultValue: message,
126
+ ...path
127
+ });
128
+ } else {
129
+ message = t(`errors.invalid_string.${issue.format}`, {
130
+ validation: t(`validations.${issue.format}`, {
131
+ defaultValue: issue.format,
132
+ ns
133
+ }),
134
+ ns,
135
+ defaultValue: message,
136
+ ...path
137
+ });
138
+ }
139
+ break;
140
+ case "too_small":
141
+ const minimum = issue.origin === "date" ? new Date(Number(issue.minimum)) : issue.minimum;
142
+ message = t(
143
+ `errors.too_small.${issue.origin}.${issue.exact ? "exact" : issue.inclusive ? "inclusive" : "not_inclusive"}`,
144
+ {
145
+ minimum,
146
+ count: typeof minimum === "number" ? minimum : void 0,
147
+ ns,
148
+ defaultValue: message,
149
+ ...path
150
+ }
151
+ );
152
+ break;
153
+ case "too_big":
154
+ const maximum = issue.origin === "date" ? new Date(Number(issue.maximum)) : issue.maximum;
155
+ message = t(
156
+ `errors.too_big.${issue.origin}.${issue.exact ? "exact" : issue.inclusive ? "inclusive" : "not_inclusive"}`,
157
+ {
158
+ maximum,
159
+ count: typeof maximum === "number" ? maximum : void 0,
160
+ ns,
161
+ defaultValue: message,
162
+ ...path
163
+ }
164
+ );
165
+ break;
166
+ case "custom":
167
+ const { key, values } = getKeyAndValues(
168
+ issue.params?.i18n,
169
+ "errors.custom"
170
+ );
171
+ message = t(key, {
172
+ ...values,
173
+ ns,
174
+ defaultValue: message,
175
+ ...path
176
+ });
177
+ break;
178
+ case "not_multiple_of":
179
+ message = t("errors.not_multiple_of", {
180
+ multipleOf: issue.divisor,
181
+ ns,
182
+ defaultValue: message,
183
+ ...path
184
+ });
185
+ break;
186
+ default:
187
+ }
188
+ return { message };
189
+ };
190
+ var zodI18nMap = makeZodI18nMap();
191
+ export {
192
+ makeZodI18nMap,
193
+ zodI18nMap
194
+ };
195
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { $ZodErrorMap } from \"zod/v4/core\";\nimport i18next, { i18n } from \"i18next\";\n\nconst jsonStringifyReplacer = (_: string, value: any): any => {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n return value;\n};\n\nfunction joinValues<T extends any[]>(array: T, separator = \" | \"): string {\n return array\n .map((val) => (typeof val === \"string\" ? `'${val}'` : val))\n .join(separator);\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => {\n if (typeof value !== \"object\" || value === null) return false;\n\n for (const key in value) {\n if (!Object.prototype.hasOwnProperty.call(value, key)) return false;\n }\n\n return true;\n};\n\nconst getKeyAndValues = (\n param: unknown,\n defaultKey: string\n): {\n values: Record<string, unknown>;\n key: string;\n} => {\n if (typeof param === \"string\") return { key: param, values: {} };\n\n if (isRecord(param)) {\n const key =\n \"key\" in param && typeof param.key === \"string\" ? param.key : defaultKey;\n const values =\n \"values\" in param && isRecord(param.values) ? param.values : {};\n return { key, values };\n }\n\n return { key: defaultKey, values: {} };\n};\n\nexport type MakeZodI18nMap = (option?: ZodI18nMapOption) => $ZodErrorMap;\n\nexport type ZodI18nMapOption = {\n t?: i18n[\"t\"];\n ns?: string | readonly string[];\n handlePath?: HandlePathOption | false;\n};\n\nexport type HandlePathOption = {\n context?: string;\n ns?: string | readonly string[];\n keyPrefix?: string;\n};\n\nconst defaultNs = \"zod\";\n\nexport const makeZodI18nMap: MakeZodI18nMap = (option) => (issue) => {\n const { t, ns, handlePath } = {\n t: i18next.t,\n ns: defaultNs,\n ...option,\n handlePath:\n option?.handlePath !== false\n ? {\n context: \"with_path\",\n ns: option?.ns ?? defaultNs,\n keyPrefix: undefined,\n ...option?.handlePath,\n }\n : null,\n };\n\n let message: string;\n message = issue.message ?? \"Invalid value\";\n\n const path =\n issue?.path && !!handlePath\n ? {\n context: handlePath.context,\n path: t(\n [handlePath.keyPrefix, issue.path.join(\".\")]\n .filter(Boolean)\n .join(\".\"),\n {\n ns: handlePath.ns,\n defaultValue: issue.path.join(\".\"),\n }\n ),\n }\n : {};\n\n switch (issue.code) {\n case \"invalid_type\":\n if (issue.expected === \"undefined\") {\n message = t(\"errors.invalid_type_received_undefined\", {\n ns,\n defaultValue: message,\n ...path,\n });\n } else if (issue.expected === \"null\") {\n message = t(\"errors.invalid_type_received_null\", {\n ns,\n defaultValue: message,\n ...path,\n });\n } else {\n message = t(\"errors.invalid_type\", {\n expected: t(`types.${issue.expected}`, {\n defaultValue: issue.expected,\n ns,\n }),\n received: t(`types.${issue.received}`, {\n defaultValue: issue.received,\n ns,\n }),\n ns,\n defaultValue: message,\n ...path,\n });\n }\n break;\n case \"invalid_value\":\n message = t(\"errors.invalid_literal\", {\n expected: JSON.stringify(issue.expected, jsonStringifyReplacer),\n ns,\n defaultValue: message,\n ...path,\n });\n break;\n case \"unrecognized_keys\":\n message = t(\"errors.unrecognized_keys\", {\n keys: joinValues(issue.keys, \", \"),\n count: issue.keys.length,\n ns,\n defaultValue: message,\n ...path,\n });\n break;\n case \"invalid_union\":\n message = t(\"errors.invalid_union\", {\n ns,\n defaultValue: message,\n ...path,\n });\n break;\n case \"invalid_format\":\n if (issue.format === \"date\") {\n message = t(\"errors.invalid_date\", {\n ns,\n defaultValue: message,\n ...path,\n });\n } else if (issue.format === \"starts_with\") {\n message = t(`errors.invalid_string.startsWith`, {\n startsWith: issue.format,\n ns,\n defaultValue: message,\n ...path,\n });\n } else if (issue.format === \"ends_with\") {\n message = t(`errors.invalid_string.endsWith`, {\n endsWith: issue.format,\n ns,\n defaultValue: message,\n ...path,\n });\n } else {\n message = t(`errors.invalid_string.${issue.format}`, {\n validation: t(`validations.${issue.format}`, {\n defaultValue: issue.format,\n ns,\n }),\n ns,\n defaultValue: message,\n ...path,\n });\n }\n break;\n case \"too_small\":\n const minimum =\n issue.origin === \"date\"\n ? new Date(Number(issue.minimum))\n : issue.minimum;\n message = t(\n `errors.too_small.${issue.origin}.${\n issue.exact\n ? \"exact\"\n : issue.inclusive\n ? \"inclusive\"\n : \"not_inclusive\"\n }`,\n {\n minimum,\n count: typeof minimum === \"number\" ? minimum : undefined,\n ns,\n defaultValue: message,\n ...path,\n }\n );\n break;\n case \"too_big\":\n const maximum =\n issue.origin === \"date\"\n ? new Date(Number(issue.maximum))\n : issue.maximum;\n message = t(\n `errors.too_big.${issue.origin}.${\n issue.exact\n ? \"exact\"\n : issue.inclusive\n ? \"inclusive\"\n : \"not_inclusive\"\n }`,\n {\n maximum,\n count: typeof maximum === \"number\" ? maximum : undefined,\n ns,\n defaultValue: message,\n ...path,\n }\n );\n break;\n case \"custom\":\n const { key, values } = getKeyAndValues(\n issue.params?.i18n,\n \"errors.custom\"\n );\n\n message = t(key, {\n ...values,\n ns,\n defaultValue: message,\n ...path,\n });\n break;\n case \"not_multiple_of\":\n message = t(\"errors.not_multiple_of\", {\n multipleOf: issue.divisor,\n ns,\n defaultValue: message,\n ...path,\n });\n break;\n default:\n }\n\n return { message };\n};\n\nexport const zodI18nMap = makeZodI18nMap();\n"],"mappings":";AACA,OAAO,aAAuB;AAE9B,IAAM,wBAAwB,CAAC,GAAW,UAAoB;AAC5D,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,MAAM,SAAS;AAAA,EACxB;AACA,SAAO;AACT;AAEA,SAAS,WAA4B,OAAU,YAAY,OAAe;AACxE,SAAO,MACJ,IAAI,CAAC,QAAS,OAAO,QAAQ,WAAW,IAAI,GAAG,MAAM,GAAI,EACzD,KAAK,SAAS;AACnB;AAEA,IAAM,WAAW,CAAC,UAAqD;AACrE,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AAExD,aAAW,OAAO,OAAO;AACvB,QAAI,CAAC,OAAO,UAAU,eAAe,KAAK,OAA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ACF,KAAK;AACH,gBAAU,EAAE,0BAA0B;AAAA,QACpC,YAAY,MAAM;AAAA,QAClB;AAAA,QACA,cAAc;AAAA,QACd,GAAG;AAAA,MACL,CAAC;AACD;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,QAAQ;AACnB;AAEO,IAAM,aAAa,eAAe;","names":[]}
@@ -0,0 +1,113 @@
1
+ {
2
+ "errors": {
3
+ "invalid_type": "المتوقع {{expected}}، المستلم {{received}}",
4
+ "invalid_type_received_undefined": "مطلوب",
5
+ "invalid_type_received_null": "مطلوب",
6
+ "invalid_literal": "قيمة حرفية غير صالحة، المتوقع {{expected}}",
7
+ "unrecognized_keys": "عنصر (عناصر) غير معروف في الكائن: {{- keys}}",
8
+ "invalid_union": "مدخل غير صالح",
9
+ "invalid_union_discriminator": "قيمة مميزة غير صالحة. المتوقع {{- options}}",
10
+ "invalid_enum_value": "قيمة تعداد غير صالحة. المتوقع {{- options}}، المستلم '{{received}}'",
11
+ "invalid_arguments": "معاملات الدالة غير صالحة",
12
+ "invalid_return_type": "نوع إرجاع دالة غير صالح",
13
+ "invalid_date": "تاريخ غير صالح",
14
+ "custom": "مدخل غير صالح",
15
+ "invalid_intersection_types": "تعذر دمج نتائج التقاطع",
16
+ "not_multiple_of": "يجب أن يكون الرقم من مضاعفات {{multipleOf}}",
17
+ "not_finite": "يجب ان يكون العدد محدود",
18
+ "invalid_string": {
19
+ "email": "غير صالح {{validation}}",
20
+ "url": "غير صالح {{validation}}",
21
+ "uuid": "غير صالح {{validation}}",
22
+ "cuid": "غير صالح {{validation}}",
23
+ "regex": "غير صالح",
24
+ "datetime": "غير صالح {{validation}}",
25
+ "startsWith": "إدخال غير صالح: يجب أن يبدأ بـ {{startsWith}}",
26
+ "endsWith": "إدخال غير صالح: يجب أن ينتهي بـ {{endsWith}}"
27
+ },
28
+ "too_small": {
29
+ "array": {
30
+ "exact": "يجب أن تحتوي المصفوفة على {{minimum}} عنصر (عناصر)",
31
+ "inclusive": "يجب أن تحتوي المصفوفة على {{minimum}} عنصر (عناصر) على الأقل",
32
+ "not_inclusive": "يجب أن تحتوي المصفوفة على أكثر من {{minimum}} عنصر (عناصر)"
33
+ },
34
+ "string": {
35
+ "exact": "يجب أن تحتوي السلسلة على {{minimum}} حرف (أحرف)",
36
+ "inclusive": "يجب أن تحتوي السلسلة على {{minimum}} حرف (أحرف) على الأقل",
37
+ "not_inclusive": "يجب أن تحتوي السلسلة على أكثر من {{minimum}} حرف (أحرف)"
38
+ },
39
+ "number": {
40
+ "exact": "يجب أن يكون الرقم {{minimum}}",
41
+ "inclusive": "يجب أن يكون الرقم أكبر من أو يساوي {{minimum}}",
42
+ "not_inclusive": "يجب أن يكون الرقم أكبر من {{minimum}}"
43
+ },
44
+ "set": {
45
+ "exact": "مدخل غير صالح",
46
+ "inclusive": "مدخل غير صالح",
47
+ "not_inclusive": "مدخل غير صالح"
48
+ },
49
+ "date": {
50
+ "exact": "يجب أن يكون التاريخ {{- minimum, datetime}}",
51
+ "inclusive": "يجب أن يكون التاريخ أكبر من أو يساوي {{- minimum, datetime}}",
52
+ "not_inclusive": "يجب أن يكون التاريخ أكبر من {{- minimum, datetime}}"
53
+ }
54
+ },
55
+ "too_big": {
56
+ "array": {
57
+ "exact": "يجب أن تحتوي المصفوفة على {{maximum}} عنصر (عناصر)",
58
+ "inclusive": "يجب أن تحتوي المصفوفة على {{maximum}} عنصر (عناصر) كحد أقصى",
59
+ "not_inclusive": "يجب أن تحتوي المصفوفة على أقل من {{maximum}} عنصر (عناصر)"
60
+ },
61
+ "string": {
62
+ "exact": "يجب أن تحتوي السلسلة على {{maximum}} حرف (أحرف)",
63
+ "inclusive": "يجب أن تحتوي السلسلة على {{maximum}} حرف (أحرف) كحد أقصى",
64
+ "not_inclusive": "يجب أن تحتوي السلسلة على أقل من {{maximum}} حرف (أحرف)"
65
+ },
66
+ "number": {
67
+ "exact": "يجب أن يكون الرقم {{maximum}}",
68
+ "inclusive": "يجب أن يكون الرقم أقل من أو يساوي {{maximum}}",
69
+ "not_inclusive": "يجب أن يكون الرقم أقل من {{maximum}}"
70
+ },
71
+ "set": {
72
+ "exact": "مدخل غير صالح",
73
+ "inclusive": "مدخل غير صالح",
74
+ "not_inclusive": "مدخل غير صالح"
75
+ },
76
+ "date": {
77
+ "exact": "يجب أن يكون التاريخ {{- maximum, datetime}}",
78
+ "inclusive": "يجب أن يكون التاريخ أصغر من أو يساوي {{- maximum, datetime}}",
79
+ "not_inclusive": "يجب أن يكون التاريخ أصغر من {{- maximum, datetime}}"
80
+ }
81
+ }
82
+ },
83
+ "validations": {
84
+ "email": "البريد الإلكتروني",
85
+ "url": "الرابط",
86
+ "uuid": "uuid",
87
+ "cuid": "cuid",
88
+ "regex": "التعبير النمطي",
89
+ "datetime": "التاريخ والوقت"
90
+ },
91
+ "types": {
92
+ "function": "دالة",
93
+ "number": "رقم",
94
+ "string": "سلسلة",
95
+ "nan": "مدخل غير رقمي",
96
+ "integer": "عدد صحيح",
97
+ "float": "عدد عشري",
98
+ "boolean": "قيمة منطقية",
99
+ "date": "تاريخ",
100
+ "bigint": "عدد صحيح كبير",
101
+ "undefined": "غير معرف",
102
+ "symbol": "رمز",
103
+ "null": "لا شيء",
104
+ "array": "مصفوفة",
105
+ "object": "كائن",
106
+ "unknown": "غير معروف",
107
+ "promise": "برومس",
108
+ "void": "بدون قيمة",
109
+ "never": "ابدا",
110
+ "map": "ماب",
111
+ "set": "مجموعة"
112
+ }
113
+ }