v2
This commit is contained in:
+138
@@ -0,0 +1,138 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "حرف", verb: "أن يحوي" },
|
||||
file: { unit: "بايت", verb: "أن يحوي" },
|
||||
array: { unit: "عنصر", verb: "أن يحوي" },
|
||||
set: { unit: "عنصر", verb: "أن يحوي" },
|
||||
map: { unit: "عنصر", verb: "أن يحوي" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "مدخل",
|
||||
email: "بريد إلكتروني",
|
||||
url: "رابط",
|
||||
emoji: "إيموجي",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "تاريخ ووقت بمعيار ISO",
|
||||
date: "تاريخ بمعيار ISO",
|
||||
time: "وقت بمعيار ISO",
|
||||
duration: "مدة بمعيار ISO",
|
||||
ipv4: "عنوان IPv4",
|
||||
ipv6: "عنوان IPv6",
|
||||
mac: "عنوان MAC",
|
||||
cidrv4: "مدى عناوين بصيغة IPv4",
|
||||
cidrv6: "مدى عناوين بصيغة IPv6",
|
||||
base64: "نَص بترميز base64-encoded",
|
||||
base64url: "نَص بترميز base64url-encoded",
|
||||
json_string: "نَص على هيئة JSON",
|
||||
e164: "رقم هاتف بمعيار E.164",
|
||||
credit_card: "رقم بطاقة الائتمان",
|
||||
currency_code: "رمز العملة",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "مدخل",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `مدخلات غير مقبولة: يفترض إدخال instanceof ${issue.expected}، ولكن تم إدخال ${received}`;
|
||||
}
|
||||
return `مدخلات غير مقبولة: يفترض إدخال ${expected}، ولكن تم إدخال ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `مدخلات غير مقبولة: يفترض إدخال ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `اختيار غير مقبول: يتوقع انتقاء أحد هذه الخيارات: ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return ` أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "عنصر"}`;
|
||||
return `أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `نَص غير مقبول: يجب أن يبدأ بـ "${issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `نَص غير مقبول: يجب أن ينتهي بـ "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `نَص غير مقبول: يجب أن يتضمَّن "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `نَص غير مقبول: يجب أن يطابق النمط ${_issue.pattern}`;
|
||||
return `${FormatDictionary[_issue.format] ?? issue.format} غير مقبول`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `رقم غير مقبول: يجب أن يكون من مضاعفات ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `معرف${issue.keys.length > 1 ? "ات" : ""} غريب${issue.keys.length > 1 ? "ة" : ""}: ${util.joinValues(issue.keys, "، ")}`;
|
||||
case "invalid_key":
|
||||
return `معرف غير مقبول في ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "مدخل غير مقبول";
|
||||
case "invalid_element":
|
||||
return `مدخل غير مقبول في ${issue.origin}`;
|
||||
default:
|
||||
return "مدخل غير مقبول";
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "حرف", verb: "أن يحوي" },
|
||||
file: { unit: "بايت", verb: "أن يحوي" },
|
||||
array: { unit: "عنصر", verb: "أن يحوي" },
|
||||
set: { unit: "عنصر", verb: "أن يحوي" },
|
||||
map: { unit: "عنصر", verb: "أن يحوي" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "مدخل",
|
||||
email: "بريد إلكتروني",
|
||||
url: "رابط",
|
||||
emoji: "إيموجي",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "تاريخ ووقت بمعيار ISO",
|
||||
date: "تاريخ بمعيار ISO",
|
||||
time: "وقت بمعيار ISO",
|
||||
duration: "مدة بمعيار ISO",
|
||||
ipv4: "عنوان IPv4",
|
||||
ipv6: "عنوان IPv6",
|
||||
mac: "عنوان MAC",
|
||||
cidrv4: "مدى عناوين بصيغة IPv4",
|
||||
cidrv6: "مدى عناوين بصيغة IPv6",
|
||||
base64: "نَص بترميز base64-encoded",
|
||||
base64url: "نَص بترميز base64url-encoded",
|
||||
json_string: "نَص على هيئة JSON",
|
||||
e164: "رقم هاتف بمعيار E.164",
|
||||
credit_card: "رقم بطاقة الائتمان",
|
||||
currency_code: "رمز العملة",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "مدخل",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `مدخلات غير مقبولة: يفترض إدخال instanceof ${issue.expected}، ولكن تم إدخال ${received}`;
|
||||
}
|
||||
return `مدخلات غير مقبولة: يفترض إدخال ${expected}، ولكن تم إدخال ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `مدخلات غير مقبولة: يفترض إدخال ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `اختيار غير مقبول: يتوقع انتقاء أحد هذه الخيارات: ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return ` أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "عنصر"}`;
|
||||
return `أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `نَص غير مقبول: يجب أن يبدأ بـ "${issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `نَص غير مقبول: يجب أن ينتهي بـ "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `نَص غير مقبول: يجب أن يتضمَّن "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `نَص غير مقبول: يجب أن يطابق النمط ${_issue.pattern}`;
|
||||
return `${FormatDictionary[_issue.format] ?? issue.format} غير مقبول`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `رقم غير مقبول: يجب أن يكون من مضاعفات ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `معرف${issue.keys.length > 1 ? "ات" : ""} غريب${issue.keys.length > 1 ? "ة" : ""}: ${util.joinValues(issue.keys, "، ")}`;
|
||||
case "invalid_key":
|
||||
return `معرف غير مقبول في ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "مدخل غير مقبول";
|
||||
case "invalid_element":
|
||||
return `مدخل غير مقبول في ${issue.origin}`;
|
||||
default:
|
||||
return "مدخل غير مقبول";
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "simvol", verb: "olmalıdır" },
|
||||
file: { unit: "bayt", verb: "olmalıdır" },
|
||||
array: { unit: "element", verb: "olmalıdır" },
|
||||
set: { unit: "element", verb: "olmalıdır" },
|
||||
map: { unit: "element", verb: "olmalıdır" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "input",
|
||||
email: "email address",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO datetime",
|
||||
date: "ISO date",
|
||||
time: "ISO time",
|
||||
duration: "ISO duration",
|
||||
ipv4: "IPv4 address",
|
||||
ipv6: "IPv6 address",
|
||||
mac: "MAC address",
|
||||
cidrv4: "IPv4 range",
|
||||
cidrv6: "IPv6 range",
|
||||
base64: "base64-encoded string",
|
||||
base64url: "base64url-encoded string",
|
||||
json_string: "JSON string",
|
||||
e164: "E.164 number",
|
||||
credit_card: "kredit kartı nömrəsi",
|
||||
currency_code: "valyuta kodu",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "input",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Yanlış dəyər: gözlənilən instanceof ${issue.expected}, daxil olan ${received}`;
|
||||
}
|
||||
return `Yanlış dəyər: gözlənilən ${expected}, daxil olan ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Yanlış dəyər: gözlənilən ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Yanlış seçim: aşağıdakılardan biri olmalıdır: ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Çox böyük: gözlənilən ${issue.origin ?? "dəyər"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "element"}`;
|
||||
return `Çox böyük: gözlənilən ${issue.origin ?? "dəyər"} ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Çox kiçik: gözlənilən ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
return `Çox kiçik: gözlənilən ${issue.origin} ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Yanlış mətn: "${_issue.prefix}" ilə başlamalıdır`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Yanlış mətn: "${_issue.suffix}" ilə bitməlidir`;
|
||||
if (_issue.format === "includes")
|
||||
return `Yanlış mətn: "${_issue.includes}" daxil olmalıdır`;
|
||||
if (_issue.format === "regex")
|
||||
return `Yanlış mətn: ${_issue.pattern} şablonuna uyğun olmalıdır`;
|
||||
return `Yanlış ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Yanlış ədəd: ${issue.divisor} ilə bölünə bilən olmalıdır`;
|
||||
case "unrecognized_keys":
|
||||
return `Tanınmayan açar${issue.keys.length > 1 ? "lar" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `${issue.origin} daxilində yanlış açar`;
|
||||
case "invalid_union":
|
||||
return "Yanlış dəyər";
|
||||
case "invalid_element":
|
||||
return `${issue.origin} daxilində yanlış dəyər`;
|
||||
default:
|
||||
return `Yanlış dəyər`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "simvol", verb: "olmalıdır" },
|
||||
file: { unit: "bayt", verb: "olmalıdır" },
|
||||
array: { unit: "element", verb: "olmalıdır" },
|
||||
set: { unit: "element", verb: "olmalıdır" },
|
||||
map: { unit: "element", verb: "olmalıdır" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "input",
|
||||
email: "email address",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO datetime",
|
||||
date: "ISO date",
|
||||
time: "ISO time",
|
||||
duration: "ISO duration",
|
||||
ipv4: "IPv4 address",
|
||||
ipv6: "IPv6 address",
|
||||
mac: "MAC address",
|
||||
cidrv4: "IPv4 range",
|
||||
cidrv6: "IPv6 range",
|
||||
base64: "base64-encoded string",
|
||||
base64url: "base64url-encoded string",
|
||||
json_string: "JSON string",
|
||||
e164: "E.164 number",
|
||||
credit_card: "kredit kartı nömrəsi",
|
||||
currency_code: "valyuta kodu",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "input",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Yanlış dəyər: gözlənilən instanceof ${issue.expected}, daxil olan ${received}`;
|
||||
}
|
||||
return `Yanlış dəyər: gözlənilən ${expected}, daxil olan ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Yanlış dəyər: gözlənilən ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Yanlış seçim: aşağıdakılardan biri olmalıdır: ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Çox böyük: gözlənilən ${issue.origin ?? "dəyər"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "element"}`;
|
||||
return `Çox böyük: gözlənilən ${issue.origin ?? "dəyər"} ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Çox kiçik: gözlənilən ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
return `Çox kiçik: gözlənilən ${issue.origin} ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Yanlış mətn: "${_issue.prefix}" ilə başlamalıdır`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Yanlış mətn: "${_issue.suffix}" ilə bitməlidir`;
|
||||
if (_issue.format === "includes")
|
||||
return `Yanlış mətn: "${_issue.includes}" daxil olmalıdır`;
|
||||
if (_issue.format === "regex")
|
||||
return `Yanlış mətn: ${_issue.pattern} şablonuna uyğun olmalıdır`;
|
||||
return `Yanlış ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Yanlış ədəd: ${issue.divisor} ilə bölünə bilən olmalıdır`;
|
||||
case "unrecognized_keys":
|
||||
return `Tanınmayan açar${issue.keys.length > 1 ? "lar" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `${issue.origin} daxilində yanlış açar`;
|
||||
case "invalid_union":
|
||||
return "Yanlış dəyər";
|
||||
case "invalid_element":
|
||||
return `${issue.origin} daxilində yanlış dəyər`;
|
||||
default:
|
||||
return `Yanlış dəyər`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
function getBelarusianPlural(count, one, few, many) {
|
||||
const absCount = Math.abs(count);
|
||||
const lastDigit = absCount % 10;
|
||||
const lastTwoDigits = absCount % 100;
|
||||
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
||||
return many;
|
||||
}
|
||||
if (lastDigit === 1) {
|
||||
return one;
|
||||
}
|
||||
if (lastDigit >= 2 && lastDigit <= 4) {
|
||||
return few;
|
||||
}
|
||||
return many;
|
||||
}
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: {
|
||||
unit: {
|
||||
one: "сімвал",
|
||||
few: "сімвалы",
|
||||
many: "сімвалаў",
|
||||
},
|
||||
verb: "мець",
|
||||
},
|
||||
array: {
|
||||
unit: {
|
||||
one: "элемент",
|
||||
few: "элементы",
|
||||
many: "элементаў",
|
||||
},
|
||||
verb: "мець",
|
||||
},
|
||||
set: {
|
||||
unit: {
|
||||
one: "элемент",
|
||||
few: "элементы",
|
||||
many: "элементаў",
|
||||
},
|
||||
verb: "мець",
|
||||
},
|
||||
map: {
|
||||
unit: {
|
||||
one: "элемент",
|
||||
few: "элементы",
|
||||
many: "элементаў",
|
||||
},
|
||||
verb: "мець",
|
||||
},
|
||||
file: {
|
||||
unit: {
|
||||
one: "байт",
|
||||
few: "байты",
|
||||
many: "байтаў",
|
||||
},
|
||||
verb: "мець",
|
||||
},
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "увод",
|
||||
email: "email адрас",
|
||||
url: "URL",
|
||||
emoji: "эмодзі",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO дата і час",
|
||||
date: "ISO дата",
|
||||
time: "ISO час",
|
||||
duration: "ISO працягласць",
|
||||
ipv4: "IPv4 адрас",
|
||||
ipv6: "IPv6 адрас",
|
||||
mac: "MAC адрас",
|
||||
cidrv4: "IPv4 дыяпазон",
|
||||
cidrv6: "IPv6 дыяпазон",
|
||||
base64: "радок у фармаце base64",
|
||||
base64url: "радок у фармаце base64url",
|
||||
json_string: "JSON радок",
|
||||
e164: "нумар E.164",
|
||||
credit_card: "нумар крэдытнай карты",
|
||||
currency_code: "код валюты",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "увод",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "лік",
|
||||
array: "масіў",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Няправільны ўвод: чакаўся instanceof ${issue.expected}, атрымана ${received}`;
|
||||
}
|
||||
return `Няправільны ўвод: чакаўся ${expected}, атрымана ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Няправільны ўвод: чакалася ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Няправільны варыянт: чакаўся адзін з ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
const maxValue = Number(issue.maximum);
|
||||
const unit = getBelarusianPlural(maxValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
|
||||
return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна ${sizing.verb} ${adj}${issue.maximum.toString()} ${unit}`;
|
||||
}
|
||||
return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна быць ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
const minValue = Number(issue.minimum);
|
||||
const unit = getBelarusianPlural(minValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
|
||||
return `Занадта малы: чакалася, што ${issue.origin} павінна ${sizing.verb} ${adj}${issue.minimum.toString()} ${unit}`;
|
||||
}
|
||||
return `Занадта малы: чакалася, што ${issue.origin} павінна быць ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Няправільны радок: павінен пачынацца з "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Няправільны радок: павінен заканчвацца на "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Няправільны радок: павінен змяшчаць "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Няправільны радок: павінен адпавядаць шаблону ${_issue.pattern}`;
|
||||
return `Няправільны ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Няправільны лік: павінен быць кратным ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Нераспазнаны ${issue.keys.length > 1 ? "ключы" : "ключ"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Няправільны ключ у ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Няправільны ўвод";
|
||||
case "invalid_element":
|
||||
return `Няправільнае значэнне ў ${issue.origin}`;
|
||||
default:
|
||||
return `Няправільны ўвод`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
import * as util from "../core/util.js";
|
||||
function getBelarusianPlural(count, one, few, many) {
|
||||
const absCount = Math.abs(count);
|
||||
const lastDigit = absCount % 10;
|
||||
const lastTwoDigits = absCount % 100;
|
||||
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
||||
return many;
|
||||
}
|
||||
if (lastDigit === 1) {
|
||||
return one;
|
||||
}
|
||||
if (lastDigit >= 2 && lastDigit <= 4) {
|
||||
return few;
|
||||
}
|
||||
return many;
|
||||
}
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: {
|
||||
unit: {
|
||||
one: "сімвал",
|
||||
few: "сімвалы",
|
||||
many: "сімвалаў",
|
||||
},
|
||||
verb: "мець",
|
||||
},
|
||||
array: {
|
||||
unit: {
|
||||
one: "элемент",
|
||||
few: "элементы",
|
||||
many: "элементаў",
|
||||
},
|
||||
verb: "мець",
|
||||
},
|
||||
set: {
|
||||
unit: {
|
||||
one: "элемент",
|
||||
few: "элементы",
|
||||
many: "элементаў",
|
||||
},
|
||||
verb: "мець",
|
||||
},
|
||||
map: {
|
||||
unit: {
|
||||
one: "элемент",
|
||||
few: "элементы",
|
||||
many: "элементаў",
|
||||
},
|
||||
verb: "мець",
|
||||
},
|
||||
file: {
|
||||
unit: {
|
||||
one: "байт",
|
||||
few: "байты",
|
||||
many: "байтаў",
|
||||
},
|
||||
verb: "мець",
|
||||
},
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "увод",
|
||||
email: "email адрас",
|
||||
url: "URL",
|
||||
emoji: "эмодзі",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO дата і час",
|
||||
date: "ISO дата",
|
||||
time: "ISO час",
|
||||
duration: "ISO працягласць",
|
||||
ipv4: "IPv4 адрас",
|
||||
ipv6: "IPv6 адрас",
|
||||
mac: "MAC адрас",
|
||||
cidrv4: "IPv4 дыяпазон",
|
||||
cidrv6: "IPv6 дыяпазон",
|
||||
base64: "радок у фармаце base64",
|
||||
base64url: "радок у фармаце base64url",
|
||||
json_string: "JSON радок",
|
||||
e164: "нумар E.164",
|
||||
credit_card: "нумар крэдытнай карты",
|
||||
currency_code: "код валюты",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "увод",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "лік",
|
||||
array: "масіў",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Няправільны ўвод: чакаўся instanceof ${issue.expected}, атрымана ${received}`;
|
||||
}
|
||||
return `Няправільны ўвод: чакаўся ${expected}, атрымана ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Няправільны ўвод: чакалася ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Няправільны варыянт: чакаўся адзін з ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
const maxValue = Number(issue.maximum);
|
||||
const unit = getBelarusianPlural(maxValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
|
||||
return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна ${sizing.verb} ${adj}${issue.maximum.toString()} ${unit}`;
|
||||
}
|
||||
return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна быць ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
const minValue = Number(issue.minimum);
|
||||
const unit = getBelarusianPlural(minValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
|
||||
return `Занадта малы: чакалася, што ${issue.origin} павінна ${sizing.verb} ${adj}${issue.minimum.toString()} ${unit}`;
|
||||
}
|
||||
return `Занадта малы: чакалася, што ${issue.origin} павінна быць ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Няправільны радок: павінен пачынацца з "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Няправільны радок: павінен заканчвацца на "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Няправільны радок: павінен змяшчаць "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Няправільны радок: павінен адпавядаць шаблону ${_issue.pattern}`;
|
||||
return `Няправільны ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Няправільны лік: павінен быць кратным ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Нераспазнаны ${issue.keys.length > 1 ? "ключы" : "ключ"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Няправільны ключ у ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Няправільны ўвод";
|
||||
case "invalid_element":
|
||||
return `Няправільнае значэнне ў ${issue.origin}`;
|
||||
default:
|
||||
return `Няправільны ўвод`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "символа", verb: "да съдържа" },
|
||||
file: { unit: "байта", verb: "да съдържа" },
|
||||
array: { unit: "елемента", verb: "да съдържа" },
|
||||
set: { unit: "елемента", verb: "да съдържа" },
|
||||
map: { unit: "елемента", verb: "да съдържа" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "вход",
|
||||
email: "имейл адрес",
|
||||
url: "URL",
|
||||
emoji: "емоджи",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO време",
|
||||
date: "ISO дата",
|
||||
time: "ISO време",
|
||||
duration: "ISO продължителност",
|
||||
ipv4: "IPv4 адрес",
|
||||
ipv6: "IPv6 адрес",
|
||||
mac: "MAC адрес",
|
||||
cidrv4: "IPv4 диапазон",
|
||||
cidrv6: "IPv6 диапазон",
|
||||
base64: "base64-кодиран низ",
|
||||
base64url: "base64url-кодиран низ",
|
||||
json_string: "JSON низ",
|
||||
e164: "E.164 номер",
|
||||
credit_card: "номер на кредитна карта",
|
||||
currency_code: "код на валута",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "вход",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "число",
|
||||
array: "масив",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Невалиден вход: очакван instanceof ${issue.expected}, получен ${received}`;
|
||||
}
|
||||
return `Невалиден вход: очакван ${expected}, получен ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Невалиден вход: очакван ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Невалидна опция: очаквано едно от ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Твърде голямо: очаква се ${issue.origin ?? "стойност"} да съдържа ${adj}${issue.maximum.toString()} ${sizing.unit ?? "елемента"}`;
|
||||
return `Твърде голямо: очаква се ${issue.origin ?? "стойност"} да бъде ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Твърде малко: очаква се ${issue.origin} да съдържа ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Твърде малко: очаква се ${issue.origin} да бъде ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `Невалиден низ: трябва да започва с "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `Невалиден низ: трябва да завършва с "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Невалиден низ: трябва да включва "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Невалиден низ: трябва да съвпада с ${_issue.pattern}`;
|
||||
let invalid_adj = "Невалиден";
|
||||
if (_issue.format === "emoji")
|
||||
invalid_adj = "Невалидно";
|
||||
if (_issue.format === "datetime")
|
||||
invalid_adj = "Невалидно";
|
||||
if (_issue.format === "date")
|
||||
invalid_adj = "Невалидна";
|
||||
if (_issue.format === "time")
|
||||
invalid_adj = "Невалидно";
|
||||
if (_issue.format === "duration")
|
||||
invalid_adj = "Невалидна";
|
||||
return `${invalid_adj} ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Невалидно число: трябва да бъде кратно на ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Неразпознат${issue.keys.length > 1 ? "и" : ""} ключ${issue.keys.length > 1 ? "ове" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Невалиден ключ в ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Невалиден вход";
|
||||
case "invalid_element":
|
||||
return `Невалидна стойност в ${issue.origin}`;
|
||||
default:
|
||||
return `Невалиден вход`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "символа", verb: "да съдържа" },
|
||||
file: { unit: "байта", verb: "да съдържа" },
|
||||
array: { unit: "елемента", verb: "да съдържа" },
|
||||
set: { unit: "елемента", verb: "да съдържа" },
|
||||
map: { unit: "елемента", verb: "да съдържа" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "вход",
|
||||
email: "имейл адрес",
|
||||
url: "URL",
|
||||
emoji: "емоджи",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO време",
|
||||
date: "ISO дата",
|
||||
time: "ISO време",
|
||||
duration: "ISO продължителност",
|
||||
ipv4: "IPv4 адрес",
|
||||
ipv6: "IPv6 адрес",
|
||||
mac: "MAC адрес",
|
||||
cidrv4: "IPv4 диапазон",
|
||||
cidrv6: "IPv6 диапазон",
|
||||
base64: "base64-кодиран низ",
|
||||
base64url: "base64url-кодиран низ",
|
||||
json_string: "JSON низ",
|
||||
e164: "E.164 номер",
|
||||
credit_card: "номер на кредитна карта",
|
||||
currency_code: "код на валута",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "вход",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "число",
|
||||
array: "масив",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Невалиден вход: очакван instanceof ${issue.expected}, получен ${received}`;
|
||||
}
|
||||
return `Невалиден вход: очакван ${expected}, получен ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Невалиден вход: очакван ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Невалидна опция: очаквано едно от ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Твърде голямо: очаква се ${issue.origin ?? "стойност"} да съдържа ${adj}${issue.maximum.toString()} ${sizing.unit ?? "елемента"}`;
|
||||
return `Твърде голямо: очаква се ${issue.origin ?? "стойност"} да бъде ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Твърде малко: очаква се ${issue.origin} да съдържа ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Твърде малко: очаква се ${issue.origin} да бъде ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `Невалиден низ: трябва да започва с "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `Невалиден низ: трябва да завършва с "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Невалиден низ: трябва да включва "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Невалиден низ: трябва да съвпада с ${_issue.pattern}`;
|
||||
let invalid_adj = "Невалиден";
|
||||
if (_issue.format === "emoji")
|
||||
invalid_adj = "Невалидно";
|
||||
if (_issue.format === "datetime")
|
||||
invalid_adj = "Невалидно";
|
||||
if (_issue.format === "date")
|
||||
invalid_adj = "Невалидна";
|
||||
if (_issue.format === "time")
|
||||
invalid_adj = "Невалидно";
|
||||
if (_issue.format === "duration")
|
||||
invalid_adj = "Невалидна";
|
||||
return `${invalid_adj} ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Невалидно число: трябва да бъде кратно на ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Неразпознат${issue.keys.length > 1 ? "и" : ""} ключ${issue.keys.length > 1 ? "ове" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Невалиден ключ в ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Невалиден вход";
|
||||
case "invalid_element":
|
||||
return `Невалидна стойност в ${issue.origin}`;
|
||||
default:
|
||||
return `Невалиден вход`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "অক্ষর", verb: "থাকতে হবে" },
|
||||
file: { unit: "বাইট", verb: "থাকতে হবে" },
|
||||
array: { unit: "আইটেম", verb: "থাকতে হবে" },
|
||||
set: { unit: "আইটেম", verb: "থাকতে হবে" },
|
||||
map: { unit: "এন্ট্রি", verb: "থাকতে হবে" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "ইনপুট",
|
||||
email: "ইমেইল ঠিকানা",
|
||||
url: "URL",
|
||||
emoji: "ইমোজি",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO তারিখ ও সময়",
|
||||
date: "ISO তারিখ",
|
||||
time: "ISO সময়",
|
||||
duration: "ISO সময়কাল",
|
||||
ipv4: "IPv4 ঠিকানা",
|
||||
ipv6: "IPv6 ঠিকানা",
|
||||
mac: "MAC ঠিকানা",
|
||||
cidrv4: "IPv4 রেঞ্জ",
|
||||
cidrv6: "IPv6 রেঞ্জ",
|
||||
base64: "base64-এনকোডেড স্ট্রিং",
|
||||
base64url: "base64url-এনকোডেড স্ট্রিং",
|
||||
json_string: "JSON স্ট্রিং",
|
||||
e164: "E.164 নম্বর",
|
||||
credit_card: "ক্রেডিট কার্ড নম্বর",
|
||||
currency_code: "মুদ্রা কোড",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "ইনপুট",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
return `অবৈধ ইনপুট: প্রত্যাশিত ${expected}, প্রাপ্ত ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `অবৈধ ইনপুট: প্রত্যাশিত ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `অবৈধ অপশন: ${util.joinValues(issue.values, " | ")} এর মধ্যে একটি প্রত্যাশিত`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `অনেক বড়: ${issue.origin ?? "মান"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "এলিমেন্ট"} হতে হবে`;
|
||||
return `অনেক বড়: ${issue.origin ?? "মান"} ${adj}${issue.maximum.toString()} হতে হবে`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `অনেক ছোট: ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} হতে হবে`;
|
||||
}
|
||||
return `অনেক ছোট: ${issue.origin} ${adj}${issue.minimum.toString()} হতে হবে`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `অবৈধ স্ট্রিং: "${_issue.prefix}" দিয়ে শুরু হতে হবে`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `অবৈধ স্ট্রিং: "${_issue.suffix}" দিয়ে শেষ হতে হবে`;
|
||||
if (_issue.format === "includes")
|
||||
return `অবৈধ স্ট্রিং: "${_issue.includes}" অন্তর্ভুক্ত থাকতে হবে`;
|
||||
if (_issue.format === "regex")
|
||||
return `অবৈধ স্ট্রিং: ${_issue.pattern} প্যাটার্ন মিলতে হবে`;
|
||||
return `অবৈধ ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `অবৈধ নম্বর: ${issue.divisor} এর গুণিতক হতে হবে`;
|
||||
case "unrecognized_keys":
|
||||
return `অচেনা কী${issue.keys.length > 1 ? "গুলো" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `${issue.origin} এ অবৈধ কী`;
|
||||
case "invalid_union":
|
||||
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
|
||||
const opts = issue.options.map((o) => `'${o}'`).join(" | ");
|
||||
return `অবৈধ ডিসক্রিমিনেটর মান। প্রত্যাশিত ${opts}`;
|
||||
}
|
||||
return "অবৈধ ইনপুট";
|
||||
case "invalid_element":
|
||||
return `${issue.origin} এ অবৈধ মান`;
|
||||
default:
|
||||
return "অবৈধ ইনপুট";
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "অক্ষর", verb: "থাকতে হবে" },
|
||||
file: { unit: "বাইট", verb: "থাকতে হবে" },
|
||||
array: { unit: "আইটেম", verb: "থাকতে হবে" },
|
||||
set: { unit: "আইটেম", verb: "থাকতে হবে" },
|
||||
map: { unit: "এন্ট্রি", verb: "থাকতে হবে" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "ইনপুট",
|
||||
email: "ইমেইল ঠিকানা",
|
||||
url: "URL",
|
||||
emoji: "ইমোজি",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO তারিখ ও সময়",
|
||||
date: "ISO তারিখ",
|
||||
time: "ISO সময়",
|
||||
duration: "ISO সময়কাল",
|
||||
ipv4: "IPv4 ঠিকানা",
|
||||
ipv6: "IPv6 ঠিকানা",
|
||||
mac: "MAC ঠিকানা",
|
||||
cidrv4: "IPv4 রেঞ্জ",
|
||||
cidrv6: "IPv6 রেঞ্জ",
|
||||
base64: "base64-এনকোডেড স্ট্রিং",
|
||||
base64url: "base64url-এনকোডেড স্ট্রিং",
|
||||
json_string: "JSON স্ট্রিং",
|
||||
e164: "E.164 নম্বর",
|
||||
credit_card: "ক্রেডিট কার্ড নম্বর",
|
||||
currency_code: "মুদ্রা কোড",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "ইনপুট",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
return `অবৈধ ইনপুট: প্রত্যাশিত ${expected}, প্রাপ্ত ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `অবৈধ ইনপুট: প্রত্যাশিত ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `অবৈধ অপশন: ${util.joinValues(issue.values, " | ")} এর মধ্যে একটি প্রত্যাশিত`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `অনেক বড়: ${issue.origin ?? "মান"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "এলিমেন্ট"} হতে হবে`;
|
||||
return `অনেক বড়: ${issue.origin ?? "মান"} ${adj}${issue.maximum.toString()} হতে হবে`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `অনেক ছোট: ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} হতে হবে`;
|
||||
}
|
||||
return `অনেক ছোট: ${issue.origin} ${adj}${issue.minimum.toString()} হতে হবে`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `অবৈধ স্ট্রিং: "${_issue.prefix}" দিয়ে শুরু হতে হবে`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `অবৈধ স্ট্রিং: "${_issue.suffix}" দিয়ে শেষ হতে হবে`;
|
||||
if (_issue.format === "includes")
|
||||
return `অবৈধ স্ট্রিং: "${_issue.includes}" অন্তর্ভুক্ত থাকতে হবে`;
|
||||
if (_issue.format === "regex")
|
||||
return `অবৈধ স্ট্রিং: ${_issue.pattern} প্যাটার্ন মিলতে হবে`;
|
||||
return `অবৈধ ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `অবৈধ নম্বর: ${issue.divisor} এর গুণিতক হতে হবে`;
|
||||
case "unrecognized_keys":
|
||||
return `অচেনা কী${issue.keys.length > 1 ? "গুলো" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `${issue.origin} এ অবৈধ কী`;
|
||||
case "invalid_union":
|
||||
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
|
||||
const opts = issue.options.map((o) => `'${o}'`).join(" | ");
|
||||
return `অবৈধ ডিসক্রিমিনেটর মান। প্রত্যাশিত ${opts}`;
|
||||
}
|
||||
return "অবৈধ ইনপুট";
|
||||
case "invalid_element":
|
||||
return `${issue.origin} এ অবৈধ মান`;
|
||||
default:
|
||||
return "অবৈধ ইনপুট";
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "caràcters", verb: "contenir" },
|
||||
file: { unit: "bytes", verb: "contenir" },
|
||||
array: { unit: "elements", verb: "contenir" },
|
||||
set: { unit: "elements", verb: "contenir" },
|
||||
map: { unit: "elements", verb: "contenir" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "entrada",
|
||||
email: "adreça electrònica",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "data i hora ISO",
|
||||
date: "data ISO",
|
||||
time: "hora ISO",
|
||||
duration: "durada ISO",
|
||||
ipv4: "adreça IPv4",
|
||||
ipv6: "adreça IPv6",
|
||||
mac: "adreça MAC",
|
||||
cidrv4: "rang IPv4",
|
||||
cidrv6: "rang IPv6",
|
||||
base64: "cadena codificada en base64",
|
||||
base64url: "cadena codificada en base64url",
|
||||
json_string: "cadena JSON",
|
||||
e164: "número E.164",
|
||||
credit_card: "número de targeta de crèdit",
|
||||
currency_code: "codi de moneda",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "entrada",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Tipus invàlid: s'esperava instanceof ${issue.expected}, s'ha rebut ${received}`;
|
||||
}
|
||||
return `Tipus invàlid: s'esperava ${expected}, s'ha rebut ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Valor invàlid: s'esperava ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Opció invàlida: s'esperava una de ${util.joinValues(issue.values, " o ")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "com a màxim" : "menys de";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Massa gran: s'esperava que ${issue.origin ?? "el valor"} contingués ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
||||
return `Massa gran: s'esperava que ${issue.origin ?? "el valor"} fos ${adj} ${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? "com a mínim" : "més de";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Massa petit: s'esperava que ${issue.origin} contingués ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Massa petit: s'esperava que ${issue.origin} fos ${adj} ${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `Format invàlid: ha de començar amb "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `Format invàlid: ha d'acabar amb "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Format invàlid: ha d'incloure "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Format invàlid: ha de coincidir amb el patró ${_issue.pattern}`;
|
||||
return `Format invàlid per a ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Número invàlid: ha de ser múltiple de ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Clau${issue.keys.length > 1 ? "s" : ""} no reconeguda${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Clau invàlida a ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Entrada invàlida"; // Could also be "Tipus d'unió invàlid" but "Entrada invàlida" is more general
|
||||
case "invalid_element":
|
||||
return `Element invàlid a ${issue.origin}`;
|
||||
default:
|
||||
return `Entrada invàlida`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "caràcters", verb: "contenir" },
|
||||
file: { unit: "bytes", verb: "contenir" },
|
||||
array: { unit: "elements", verb: "contenir" },
|
||||
set: { unit: "elements", verb: "contenir" },
|
||||
map: { unit: "elements", verb: "contenir" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "entrada",
|
||||
email: "adreça electrònica",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "data i hora ISO",
|
||||
date: "data ISO",
|
||||
time: "hora ISO",
|
||||
duration: "durada ISO",
|
||||
ipv4: "adreça IPv4",
|
||||
ipv6: "adreça IPv6",
|
||||
mac: "adreça MAC",
|
||||
cidrv4: "rang IPv4",
|
||||
cidrv6: "rang IPv6",
|
||||
base64: "cadena codificada en base64",
|
||||
base64url: "cadena codificada en base64url",
|
||||
json_string: "cadena JSON",
|
||||
e164: "número E.164",
|
||||
credit_card: "número de targeta de crèdit",
|
||||
currency_code: "codi de moneda",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "entrada",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Tipus invàlid: s'esperava instanceof ${issue.expected}, s'ha rebut ${received}`;
|
||||
}
|
||||
return `Tipus invàlid: s'esperava ${expected}, s'ha rebut ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Valor invàlid: s'esperava ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Opció invàlida: s'esperava una de ${util.joinValues(issue.values, " o ")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "com a màxim" : "menys de";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Massa gran: s'esperava que ${issue.origin ?? "el valor"} contingués ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
||||
return `Massa gran: s'esperava que ${issue.origin ?? "el valor"} fos ${adj} ${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? "com a mínim" : "més de";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Massa petit: s'esperava que ${issue.origin} contingués ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Massa petit: s'esperava que ${issue.origin} fos ${adj} ${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `Format invàlid: ha de començar amb "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `Format invàlid: ha d'acabar amb "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Format invàlid: ha d'incloure "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Format invàlid: ha de coincidir amb el patró ${_issue.pattern}`;
|
||||
return `Format invàlid per a ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Número invàlid: ha de ser múltiple de ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Clau${issue.keys.length > 1 ? "s" : ""} no reconeguda${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Clau invàlida a ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Entrada invàlida"; // Could also be "Tipus d'unió invàlid" but "Entrada invàlida" is more general
|
||||
case "invalid_element":
|
||||
return `Element invàlid a ${issue.origin}`;
|
||||
default:
|
||||
return `Entrada invàlida`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "پیت", verb: "بێت" },
|
||||
file: { unit: "بایت", verb: "بێت" },
|
||||
array: { unit: "دانە", verb: "بێت" },
|
||||
set: { unit: "دانە", verb: "بێت" },
|
||||
map: { unit: "دانە", verb: "بێت" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "regex",
|
||||
email: "ئیمەیڵ",
|
||||
url: "بەستەر (URL)",
|
||||
emoji: "ئیمۆجی",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ڕێکەوت و کات",
|
||||
date: "ڕێکەوت",
|
||||
time: "کات",
|
||||
duration: "ماوە",
|
||||
ipv4: "ناونیشانی IPv4",
|
||||
ipv6: "ناونیشانی IPv6",
|
||||
mac: "ناونیشانی MAC",
|
||||
cidrv4: "مەودای IPv4",
|
||||
cidrv6: "مەودای IPv6",
|
||||
base64: "دەقی base64",
|
||||
base64url: "دەقی base64url",
|
||||
json_string: "دەقی JSON",
|
||||
e164: "ژمارەی E.164",
|
||||
credit_card: "ژمارەی کارتی کرێدیت",
|
||||
currency_code: "کۆدی دراو",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "تێکردە",
|
||||
};
|
||||
// type names: missing keys = do not translate (use raw value via ?? fallback)
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
string: "نووسین",
|
||||
number: "ژمارە",
|
||||
boolean: "boolean",
|
||||
array: "array",
|
||||
object: "object",
|
||||
date: "ڕێکەوت",
|
||||
integer: "ژمارە",
|
||||
float: "ژمارە",
|
||||
null: "null",
|
||||
undefined: "undefined",
|
||||
function: "function",
|
||||
symbol: "symbol",
|
||||
unknown: "unknown",
|
||||
promise: "promise",
|
||||
void: "void",
|
||||
never: "never",
|
||||
map: "map",
|
||||
set: "set",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
const postfix = ["ا", "و", "ۆ", "وو", "ە", "ی", "ێ"].some((p) => received.endsWith(p)) ? "یە" : "ە";
|
||||
const isEnglish = /^[a-zA-Z]+$/.test(received);
|
||||
if (receivedType === "null" || receivedType === "undefined")
|
||||
return `داواکراوە`;
|
||||
return `چاوەڕوانکراوە ${expected} بێت، بەڵام ${received}${isEnglish ? "" : postfix}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `بەهاکە نادرووستە: چاوەڕوانکراوە ${util.stringifyPrimitive(issue.values[0])} بێت`;
|
||||
return `هەڵبژاردەی نادروست: چاوەڕوانکراوە یەکێک بێت لە ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `پێویستە بە لایەنی زۆرەوە ${issue.maximum.toString()} ${sizing.unit} ${sizing.verb}`;
|
||||
return `پێویستە بە لایەنی زۆرەوە ${issue.maximum.toString()} بێت`;
|
||||
}
|
||||
case "too_small": {
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `پێویستە بە لایەنی کەمەوە ${issue.minimum.toString()} ${sizing.unit} ${sizing.verb}`;
|
||||
return `پێویستە بە لایەنی کەمەوە ${issue.minimum.toString()} بێت`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `دەقی نادروست: پێویستە دەستپێبکات بە "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `دەقی نادروست: پێویستە کۆتاییبێت بە "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `دەقی نادروست: پێویستە "${_issue.includes}" لەخۆبگرێت`;
|
||||
if (_issue.format === "regex")
|
||||
return `دەقی نادروست: پێویستە لەگەڵ پاتێرنی ${_issue.pattern} بگونجێت`;
|
||||
return `بەهای ${FormatDictionary[_issue.format] ?? issue.format} نادروستە`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `ژمارەی نادروست: دەبێت چەند هێندە بێت بۆ ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `کلیلی نەناسراو: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `کلیلی نادروست لە ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
|
||||
const opts = issue.options.map((o) => `'${o}'`).join(" | ");
|
||||
return `بەهای نەناسراو هەیە. بەهای چاوەڕوانکراو: ${opts}`;
|
||||
}
|
||||
return "یەکگرتنی نادروست";
|
||||
case "invalid_element":
|
||||
return `${issue.origin} بەهاکە نادروستە`;
|
||||
default:
|
||||
return `تێکردەی نادروست`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "پیت", verb: "بێت" },
|
||||
file: { unit: "بایت", verb: "بێت" },
|
||||
array: { unit: "دانە", verb: "بێت" },
|
||||
set: { unit: "دانە", verb: "بێت" },
|
||||
map: { unit: "دانە", verb: "بێت" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "regex",
|
||||
email: "ئیمەیڵ",
|
||||
url: "بەستەر (URL)",
|
||||
emoji: "ئیمۆجی",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ڕێکەوت و کات",
|
||||
date: "ڕێکەوت",
|
||||
time: "کات",
|
||||
duration: "ماوە",
|
||||
ipv4: "ناونیشانی IPv4",
|
||||
ipv6: "ناونیشانی IPv6",
|
||||
mac: "ناونیشانی MAC",
|
||||
cidrv4: "مەودای IPv4",
|
||||
cidrv6: "مەودای IPv6",
|
||||
base64: "دەقی base64",
|
||||
base64url: "دەقی base64url",
|
||||
json_string: "دەقی JSON",
|
||||
e164: "ژمارەی E.164",
|
||||
credit_card: "ژمارەی کارتی کرێدیت",
|
||||
currency_code: "کۆدی دراو",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "تێکردە",
|
||||
};
|
||||
// type names: missing keys = do not translate (use raw value via ?? fallback)
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
string: "نووسین",
|
||||
number: "ژمارە",
|
||||
boolean: "boolean",
|
||||
array: "array",
|
||||
object: "object",
|
||||
date: "ڕێکەوت",
|
||||
integer: "ژمارە",
|
||||
float: "ژمارە",
|
||||
null: "null",
|
||||
undefined: "undefined",
|
||||
function: "function",
|
||||
symbol: "symbol",
|
||||
unknown: "unknown",
|
||||
promise: "promise",
|
||||
void: "void",
|
||||
never: "never",
|
||||
map: "map",
|
||||
set: "set",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
const postfix = ["ا", "و", "ۆ", "وو", "ە", "ی", "ێ"].some((p) => received.endsWith(p)) ? "یە" : "ە";
|
||||
const isEnglish = /^[a-zA-Z]+$/.test(received);
|
||||
if (receivedType === "null" || receivedType === "undefined")
|
||||
return `داواکراوە`;
|
||||
return `چاوەڕوانکراوە ${expected} بێت، بەڵام ${received}${isEnglish ? "" : postfix}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `بەهاکە نادرووستە: چاوەڕوانکراوە ${util.stringifyPrimitive(issue.values[0])} بێت`;
|
||||
return `هەڵبژاردەی نادروست: چاوەڕوانکراوە یەکێک بێت لە ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `پێویستە بە لایەنی زۆرەوە ${issue.maximum.toString()} ${sizing.unit} ${sizing.verb}`;
|
||||
return `پێویستە بە لایەنی زۆرەوە ${issue.maximum.toString()} بێت`;
|
||||
}
|
||||
case "too_small": {
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `پێویستە بە لایەنی کەمەوە ${issue.minimum.toString()} ${sizing.unit} ${sizing.verb}`;
|
||||
return `پێویستە بە لایەنی کەمەوە ${issue.minimum.toString()} بێت`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `دەقی نادروست: پێویستە دەستپێبکات بە "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `دەقی نادروست: پێویستە کۆتاییبێت بە "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `دەقی نادروست: پێویستە "${_issue.includes}" لەخۆبگرێت`;
|
||||
if (_issue.format === "regex")
|
||||
return `دەقی نادروست: پێویستە لەگەڵ پاتێرنی ${_issue.pattern} بگونجێت`;
|
||||
return `بەهای ${FormatDictionary[_issue.format] ?? issue.format} نادروستە`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `ژمارەی نادروست: دەبێت چەند هێندە بێت بۆ ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `کلیلی نەناسراو: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `کلیلی نادروست لە ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
|
||||
const opts = issue.options.map((o) => `'${o}'`).join(" | ");
|
||||
return `بەهای نەناسراو هەیە. بەهای چاوەڕوانکراو: ${opts}`;
|
||||
}
|
||||
return "یەکگرتنی نادروست";
|
||||
case "invalid_element":
|
||||
return `${issue.origin} بەهاکە نادروستە`;
|
||||
default:
|
||||
return `تێکردەی نادروست`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "znaků", verb: "mít" },
|
||||
file: { unit: "bajtů", verb: "mít" },
|
||||
array: { unit: "prvků", verb: "mít" },
|
||||
set: { unit: "prvků", verb: "mít" },
|
||||
map: { unit: "prvků", verb: "mít" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "regulární výraz",
|
||||
email: "e-mailová adresa",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "datum a čas ve formátu ISO",
|
||||
date: "datum ve formátu ISO",
|
||||
time: "čas ve formátu ISO",
|
||||
duration: "doba trvání ISO",
|
||||
ipv4: "IPv4 adresa",
|
||||
ipv6: "IPv6 adresa",
|
||||
mac: "MAC adresa",
|
||||
cidrv4: "rozsah IPv4",
|
||||
cidrv6: "rozsah IPv6",
|
||||
base64: "řetězec zakódovaný ve formátu base64",
|
||||
base64url: "řetězec zakódovaný ve formátu base64url",
|
||||
json_string: "řetězec ve formátu JSON",
|
||||
e164: "číslo E.164",
|
||||
credit_card: "číslo kreditní karty",
|
||||
currency_code: "kód měny",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "vstup",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "číslo",
|
||||
string: "řetězec",
|
||||
function: "funkce",
|
||||
array: "pole",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Neplatný vstup: očekáváno instanceof ${issue.expected}, obdrženo ${received}`;
|
||||
}
|
||||
return `Neplatný vstup: očekáváno ${expected}, obdrženo ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Neplatný vstup: očekáváno ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Neplatná možnost: očekávána jedna z hodnot ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Hodnota je příliš velká: ${issue.origin ?? "hodnota"} musí mít ${adj}${issue.maximum.toString()} ${sizing.unit ?? "prvků"}`;
|
||||
}
|
||||
return `Hodnota je příliš velká: ${issue.origin ?? "hodnota"} musí být ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Hodnota je příliš malá: ${issue.origin ?? "hodnota"} musí mít ${adj}${issue.minimum.toString()} ${sizing.unit ?? "prvků"}`;
|
||||
}
|
||||
return `Hodnota je příliš malá: ${issue.origin ?? "hodnota"} musí být ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Neplatný řetězec: musí začínat na "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Neplatný řetězec: musí končit na "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Neplatný řetězec: musí obsahovat "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Neplatný řetězec: musí odpovídat vzoru ${_issue.pattern}`;
|
||||
return `Neplatný formát ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Neplatné číslo: musí být násobkem ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Neznámé klíče: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Neplatný klíč v ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Neplatný vstup";
|
||||
case "invalid_element":
|
||||
return `Neplatná hodnota v ${issue.origin}`;
|
||||
default:
|
||||
return `Neplatný vstup`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "znaků", verb: "mít" },
|
||||
file: { unit: "bajtů", verb: "mít" },
|
||||
array: { unit: "prvků", verb: "mít" },
|
||||
set: { unit: "prvků", verb: "mít" },
|
||||
map: { unit: "prvků", verb: "mít" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "regulární výraz",
|
||||
email: "e-mailová adresa",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "datum a čas ve formátu ISO",
|
||||
date: "datum ve formátu ISO",
|
||||
time: "čas ve formátu ISO",
|
||||
duration: "doba trvání ISO",
|
||||
ipv4: "IPv4 adresa",
|
||||
ipv6: "IPv6 adresa",
|
||||
mac: "MAC adresa",
|
||||
cidrv4: "rozsah IPv4",
|
||||
cidrv6: "rozsah IPv6",
|
||||
base64: "řetězec zakódovaný ve formátu base64",
|
||||
base64url: "řetězec zakódovaný ve formátu base64url",
|
||||
json_string: "řetězec ve formátu JSON",
|
||||
e164: "číslo E.164",
|
||||
credit_card: "číslo kreditní karty",
|
||||
currency_code: "kód měny",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "vstup",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "číslo",
|
||||
string: "řetězec",
|
||||
function: "funkce",
|
||||
array: "pole",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Neplatný vstup: očekáváno instanceof ${issue.expected}, obdrženo ${received}`;
|
||||
}
|
||||
return `Neplatný vstup: očekáváno ${expected}, obdrženo ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Neplatný vstup: očekáváno ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Neplatná možnost: očekávána jedna z hodnot ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Hodnota je příliš velká: ${issue.origin ?? "hodnota"} musí mít ${adj}${issue.maximum.toString()} ${sizing.unit ?? "prvků"}`;
|
||||
}
|
||||
return `Hodnota je příliš velká: ${issue.origin ?? "hodnota"} musí být ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Hodnota je příliš malá: ${issue.origin ?? "hodnota"} musí mít ${adj}${issue.minimum.toString()} ${sizing.unit ?? "prvků"}`;
|
||||
}
|
||||
return `Hodnota je příliš malá: ${issue.origin ?? "hodnota"} musí být ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Neplatný řetězec: musí začínat na "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Neplatný řetězec: musí končit na "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Neplatný řetězec: musí obsahovat "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Neplatný řetězec: musí odpovídat vzoru ${_issue.pattern}`;
|
||||
return `Neplatný formát ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Neplatné číslo: musí být násobkem ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Neznámé klíče: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Neplatný klíč v ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Neplatný vstup";
|
||||
case "invalid_element":
|
||||
return `Neplatná hodnota v ${issue.origin}`;
|
||||
default:
|
||||
return `Neplatný vstup`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "tegn", verb: "havde" },
|
||||
file: { unit: "bytes", verb: "havde" },
|
||||
array: { unit: "elementer", verb: "indeholdt" },
|
||||
set: { unit: "elementer", verb: "indeholdt" },
|
||||
map: { unit: "elementer", verb: "indeholdt" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "input",
|
||||
email: "e-mailadresse",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO dato- og klokkeslæt",
|
||||
date: "ISO-dato",
|
||||
time: "ISO-klokkeslæt",
|
||||
duration: "ISO-varighed",
|
||||
ipv4: "IPv4-adresse",
|
||||
ipv6: "IPv6-adresse",
|
||||
mac: "MAC-adresse",
|
||||
cidrv4: "IPv4-spektrum",
|
||||
cidrv6: "IPv6-spektrum",
|
||||
base64: "base64-kodet streng",
|
||||
base64url: "base64url-kodet streng",
|
||||
json_string: "JSON-streng",
|
||||
e164: "E.164-nummer",
|
||||
credit_card: "kreditkortnummer",
|
||||
currency_code: "valutakode",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "input",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
string: "streng",
|
||||
number: "tal",
|
||||
boolean: "boolean",
|
||||
array: "liste",
|
||||
object: "objekt",
|
||||
set: "sæt",
|
||||
file: "fil",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Ugyldigt input: forventede instanceof ${issue.expected}, fik ${received}`;
|
||||
}
|
||||
return `Ugyldigt input: forventede ${expected}, fik ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Ugyldig værdi: forventede ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Ugyldigt valg: forventede en af følgende ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
const origin = TypeDictionary[issue.origin] ?? issue.origin;
|
||||
if (sizing)
|
||||
return `For stor: forventede ${origin ?? "value"} ${sizing.verb} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "elementer"}`;
|
||||
return `For stor: forventede ${origin ?? "value"} havde ${adj} ${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
const origin = TypeDictionary[issue.origin] ?? issue.origin;
|
||||
if (sizing) {
|
||||
return `For lille: forventede ${origin} ${sizing.verb} ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `For lille: forventede ${origin} havde ${adj} ${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Ugyldig streng: skal starte med "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Ugyldig streng: skal ende med "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Ugyldig streng: skal indeholde "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Ugyldig streng: skal matche mønsteret ${_issue.pattern}`;
|
||||
return `Ugyldig ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Ugyldigt tal: skal være deleligt med ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `${issue.keys.length > 1 ? "Ukendte nøgler" : "Ukendt nøgle"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Ugyldig nøgle i ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Ugyldigt input: matcher ingen af de tilladte typer";
|
||||
case "invalid_element":
|
||||
return `Ugyldig værdi i ${issue.origin}`;
|
||||
default:
|
||||
return `Ugyldigt input`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "tegn", verb: "havde" },
|
||||
file: { unit: "bytes", verb: "havde" },
|
||||
array: { unit: "elementer", verb: "indeholdt" },
|
||||
set: { unit: "elementer", verb: "indeholdt" },
|
||||
map: { unit: "elementer", verb: "indeholdt" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "input",
|
||||
email: "e-mailadresse",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO dato- og klokkeslæt",
|
||||
date: "ISO-dato",
|
||||
time: "ISO-klokkeslæt",
|
||||
duration: "ISO-varighed",
|
||||
ipv4: "IPv4-adresse",
|
||||
ipv6: "IPv6-adresse",
|
||||
mac: "MAC-adresse",
|
||||
cidrv4: "IPv4-spektrum",
|
||||
cidrv6: "IPv6-spektrum",
|
||||
base64: "base64-kodet streng",
|
||||
base64url: "base64url-kodet streng",
|
||||
json_string: "JSON-streng",
|
||||
e164: "E.164-nummer",
|
||||
credit_card: "kreditkortnummer",
|
||||
currency_code: "valutakode",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "input",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
string: "streng",
|
||||
number: "tal",
|
||||
boolean: "boolean",
|
||||
array: "liste",
|
||||
object: "objekt",
|
||||
set: "sæt",
|
||||
file: "fil",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Ugyldigt input: forventede instanceof ${issue.expected}, fik ${received}`;
|
||||
}
|
||||
return `Ugyldigt input: forventede ${expected}, fik ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Ugyldig værdi: forventede ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Ugyldigt valg: forventede en af følgende ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
const origin = TypeDictionary[issue.origin] ?? issue.origin;
|
||||
if (sizing)
|
||||
return `For stor: forventede ${origin ?? "value"} ${sizing.verb} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "elementer"}`;
|
||||
return `For stor: forventede ${origin ?? "value"} havde ${adj} ${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
const origin = TypeDictionary[issue.origin] ?? issue.origin;
|
||||
if (sizing) {
|
||||
return `For lille: forventede ${origin} ${sizing.verb} ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `For lille: forventede ${origin} havde ${adj} ${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Ugyldig streng: skal starte med "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Ugyldig streng: skal ende med "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Ugyldig streng: skal indeholde "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Ugyldig streng: skal matche mønsteret ${_issue.pattern}`;
|
||||
return `Ugyldig ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Ugyldigt tal: skal være deleligt med ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `${issue.keys.length > 1 ? "Ukendte nøgler" : "Ukendt nøgle"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Ugyldig nøgle i ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Ugyldigt input: matcher ingen af de tilladte typer";
|
||||
case "invalid_element":
|
||||
return `Ugyldig værdi i ${issue.origin}`;
|
||||
default:
|
||||
return `Ugyldigt input`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "Zeichen", verb: "zu haben" },
|
||||
file: { unit: "Bytes", verb: "zu haben" },
|
||||
array: { unit: "Elemente", verb: "zu haben" },
|
||||
set: { unit: "Elemente", verb: "zu haben" },
|
||||
map: { unit: "Elemente", verb: "zu haben" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "Eingabe",
|
||||
email: "E-Mail-Adresse",
|
||||
url: "URL",
|
||||
emoji: "Emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO-Datum und -Uhrzeit",
|
||||
date: "ISO-Datum",
|
||||
time: "ISO-Uhrzeit",
|
||||
duration: "ISO-Dauer",
|
||||
ipv4: "IPv4-Adresse",
|
||||
ipv6: "IPv6-Adresse",
|
||||
mac: "MAC-Adresse",
|
||||
cidrv4: "IPv4-Bereich",
|
||||
cidrv6: "IPv6-Bereich",
|
||||
base64: "Base64-codierter String",
|
||||
base64url: "Base64-URL-codierter String",
|
||||
json_string: "JSON-String",
|
||||
e164: "E.164-Nummer",
|
||||
credit_card: "Kreditkartennummer",
|
||||
currency_code: "Währungscode",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "Eingabe",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "Zahl",
|
||||
array: "Array",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Ungültige Eingabe: erwartet instanceof ${issue.expected}, erhalten ${received}`;
|
||||
}
|
||||
return `Ungültige Eingabe: erwartet ${expected}, erhalten ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Ungültige Eingabe: erwartet ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Ungültige Option: erwartet eine von ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Zu groß: erwartet, dass ${issue.origin ?? "Wert"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "Elemente"} hat`;
|
||||
return `Zu groß: erwartet, dass ${issue.origin ?? "Wert"} ${adj}${issue.maximum.toString()} ist`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Zu klein: erwartet, dass ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} hat`;
|
||||
}
|
||||
return `Zu klein: erwartet, dass ${issue.origin} ${adj}${issue.minimum.toString()} ist`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Ungültiger String: muss mit "${_issue.prefix}" beginnen`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Ungültiger String: muss mit "${_issue.suffix}" enden`;
|
||||
if (_issue.format === "includes")
|
||||
return `Ungültiger String: muss "${_issue.includes}" enthalten`;
|
||||
if (_issue.format === "regex")
|
||||
return `Ungültiger String: muss dem Muster ${_issue.pattern} entsprechen`;
|
||||
return `Ungültig: ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Ungültige Zahl: muss ein Vielfaches von ${issue.divisor} sein`;
|
||||
case "unrecognized_keys":
|
||||
return `${issue.keys.length > 1 ? "Unbekannte Schlüssel" : "Unbekannter Schlüssel"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Ungültiger Schlüssel in ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Ungültige Eingabe";
|
||||
case "invalid_element":
|
||||
return `Ungültiger Wert in ${issue.origin}`;
|
||||
default:
|
||||
return `Ungültige Eingabe`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "Zeichen", verb: "zu haben" },
|
||||
file: { unit: "Bytes", verb: "zu haben" },
|
||||
array: { unit: "Elemente", verb: "zu haben" },
|
||||
set: { unit: "Elemente", verb: "zu haben" },
|
||||
map: { unit: "Elemente", verb: "zu haben" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "Eingabe",
|
||||
email: "E-Mail-Adresse",
|
||||
url: "URL",
|
||||
emoji: "Emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO-Datum und -Uhrzeit",
|
||||
date: "ISO-Datum",
|
||||
time: "ISO-Uhrzeit",
|
||||
duration: "ISO-Dauer",
|
||||
ipv4: "IPv4-Adresse",
|
||||
ipv6: "IPv6-Adresse",
|
||||
mac: "MAC-Adresse",
|
||||
cidrv4: "IPv4-Bereich",
|
||||
cidrv6: "IPv6-Bereich",
|
||||
base64: "Base64-codierter String",
|
||||
base64url: "Base64-URL-codierter String",
|
||||
json_string: "JSON-String",
|
||||
e164: "E.164-Nummer",
|
||||
credit_card: "Kreditkartennummer",
|
||||
currency_code: "Währungscode",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "Eingabe",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "Zahl",
|
||||
array: "Array",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Ungültige Eingabe: erwartet instanceof ${issue.expected}, erhalten ${received}`;
|
||||
}
|
||||
return `Ungültige Eingabe: erwartet ${expected}, erhalten ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Ungültige Eingabe: erwartet ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Ungültige Option: erwartet eine von ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Zu groß: erwartet, dass ${issue.origin ?? "Wert"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "Elemente"} hat`;
|
||||
return `Zu groß: erwartet, dass ${issue.origin ?? "Wert"} ${adj}${issue.maximum.toString()} ist`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Zu klein: erwartet, dass ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} hat`;
|
||||
}
|
||||
return `Zu klein: erwartet, dass ${issue.origin} ${adj}${issue.minimum.toString()} ist`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Ungültiger String: muss mit "${_issue.prefix}" beginnen`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Ungültiger String: muss mit "${_issue.suffix}" enden`;
|
||||
if (_issue.format === "includes")
|
||||
return `Ungültiger String: muss "${_issue.includes}" enthalten`;
|
||||
if (_issue.format === "regex")
|
||||
return `Ungültiger String: muss dem Muster ${_issue.pattern} entsprechen`;
|
||||
return `Ungültig: ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Ungültige Zahl: muss ein Vielfaches von ${issue.divisor} sein`;
|
||||
case "unrecognized_keys":
|
||||
return `${issue.keys.length > 1 ? "Unbekannte Schlüssel" : "Unbekannter Schlüssel"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Ungültiger Schlüssel in ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Ungültige Eingabe";
|
||||
case "invalid_element":
|
||||
return `Ungültiger Wert in ${issue.origin}`;
|
||||
default:
|
||||
return `Ungültige Eingabe`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "χαρακτήρες", verb: "να έχει" },
|
||||
file: { unit: "bytes", verb: "να έχει" },
|
||||
array: { unit: "στοιχεία", verb: "να έχει" },
|
||||
set: { unit: "στοιχεία", verb: "να έχει" },
|
||||
map: { unit: "καταχωρήσεις", verb: "να έχει" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "είσοδος",
|
||||
email: "διεύθυνση email",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO ημερομηνία και ώρα",
|
||||
date: "ISO ημερομηνία",
|
||||
time: "ISO ώρα",
|
||||
duration: "ISO διάρκεια",
|
||||
ipv4: "διεύθυνση IPv4",
|
||||
ipv6: "διεύθυνση IPv6",
|
||||
mac: "διεύθυνση MAC",
|
||||
cidrv4: "εύρος IPv4",
|
||||
cidrv6: "εύρος IPv6",
|
||||
base64: "συμβολοσειρά κωδικοποιημένη σε base64",
|
||||
base64url: "συμβολοσειρά κωδικοποιημένη σε base64url",
|
||||
json_string: "συμβολοσειρά JSON",
|
||||
e164: "αριθμός E.164",
|
||||
credit_card: "αριθμός πιστωτικής κάρτας",
|
||||
currency_code: "κωδικός νομίσματος",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "είσοδος",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (typeof issue.expected === "string" && /^[A-Z]/.test(issue.expected)) {
|
||||
return `Μη έγκυρη είσοδος: αναμενόταν instanceof ${issue.expected}, λήφθηκε ${received}`;
|
||||
}
|
||||
return `Μη έγκυρη είσοδος: αναμενόταν ${expected}, λήφθηκε ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Μη έγκυρη είσοδος: αναμενόταν ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Μη έγκυρη επιλογή: αναμενόταν ένα από ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Πολύ μεγάλο: αναμενόταν ${issue.origin ?? "τιμή"} να έχει ${adj}${issue.maximum.toString()} ${sizing.unit ?? "στοιχεία"}`;
|
||||
return `Πολύ μεγάλο: αναμενόταν ${issue.origin ?? "τιμή"} να είναι ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Πολύ μικρό: αναμενόταν ${issue.origin} να έχει ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Πολύ μικρό: αναμενόταν ${issue.origin} να είναι ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `Μη έγκυρη συμβολοσειρά: πρέπει να ξεκινά με "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `Μη έγκυρη συμβολοσειρά: πρέπει να τελειώνει με "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Μη έγκυρη συμβολοσειρά: πρέπει να περιέχει "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Μη έγκυρη συμβολοσειρά: πρέπει να ταιριάζει με το μοτίβο ${_issue.pattern}`;
|
||||
return `Μη έγκυρο: ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Μη έγκυρος αριθμός: πρέπει να είναι πολλαπλάσιο του ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Άγνωστ${issue.keys.length > 1 ? "α" : "ο"} κλειδ${issue.keys.length > 1 ? "ιά" : "ί"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Μη έγκυρο κλειδί στο ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Μη έγκυρη είσοδος";
|
||||
case "invalid_element":
|
||||
return `Μη έγκυρη τιμή στο ${issue.origin}`;
|
||||
default:
|
||||
return `Μη έγκυρη είσοδος`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "χαρακτήρες", verb: "να έχει" },
|
||||
file: { unit: "bytes", verb: "να έχει" },
|
||||
array: { unit: "στοιχεία", verb: "να έχει" },
|
||||
set: { unit: "στοιχεία", verb: "να έχει" },
|
||||
map: { unit: "καταχωρήσεις", verb: "να έχει" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "είσοδος",
|
||||
email: "διεύθυνση email",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO ημερομηνία και ώρα",
|
||||
date: "ISO ημερομηνία",
|
||||
time: "ISO ώρα",
|
||||
duration: "ISO διάρκεια",
|
||||
ipv4: "διεύθυνση IPv4",
|
||||
ipv6: "διεύθυνση IPv6",
|
||||
mac: "διεύθυνση MAC",
|
||||
cidrv4: "εύρος IPv4",
|
||||
cidrv6: "εύρος IPv6",
|
||||
base64: "συμβολοσειρά κωδικοποιημένη σε base64",
|
||||
base64url: "συμβολοσειρά κωδικοποιημένη σε base64url",
|
||||
json_string: "συμβολοσειρά JSON",
|
||||
e164: "αριθμός E.164",
|
||||
credit_card: "αριθμός πιστωτικής κάρτας",
|
||||
currency_code: "κωδικός νομίσματος",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "είσοδος",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (typeof issue.expected === "string" && /^[A-Z]/.test(issue.expected)) {
|
||||
return `Μη έγκυρη είσοδος: αναμενόταν instanceof ${issue.expected}, λήφθηκε ${received}`;
|
||||
}
|
||||
return `Μη έγκυρη είσοδος: αναμενόταν ${expected}, λήφθηκε ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Μη έγκυρη είσοδος: αναμενόταν ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Μη έγκυρη επιλογή: αναμενόταν ένα από ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Πολύ μεγάλο: αναμενόταν ${issue.origin ?? "τιμή"} να έχει ${adj}${issue.maximum.toString()} ${sizing.unit ?? "στοιχεία"}`;
|
||||
return `Πολύ μεγάλο: αναμενόταν ${issue.origin ?? "τιμή"} να είναι ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Πολύ μικρό: αναμενόταν ${issue.origin} να έχει ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Πολύ μικρό: αναμενόταν ${issue.origin} να είναι ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `Μη έγκυρη συμβολοσειρά: πρέπει να ξεκινά με "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `Μη έγκυρη συμβολοσειρά: πρέπει να τελειώνει με "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Μη έγκυρη συμβολοσειρά: πρέπει να περιέχει "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Μη έγκυρη συμβολοσειρά: πρέπει να ταιριάζει με το μοτίβο ${_issue.pattern}`;
|
||||
return `Μη έγκυρο: ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Μη έγκυρος αριθμός: πρέπει να είναι πολλαπλάσιο του ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Άγνωστ${issue.keys.length > 1 ? "α" : "ο"} κλειδ${issue.keys.length > 1 ? "ιά" : "ί"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Μη έγκυρο κλειδί στο ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Μη έγκυρη είσοδος";
|
||||
case "invalid_element":
|
||||
return `Μη έγκυρη τιμή στο ${issue.origin}`;
|
||||
default:
|
||||
return `Μη έγκυρη είσοδος`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "characters", verb: "to have" },
|
||||
file: { unit: "bytes", verb: "to have" },
|
||||
array: { unit: "items", verb: "to have" },
|
||||
set: { unit: "items", verb: "to have" },
|
||||
map: { unit: "entries", verb: "to have" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "input",
|
||||
email: "email address",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO datetime",
|
||||
date: "ISO date",
|
||||
time: "ISO time",
|
||||
duration: "ISO duration",
|
||||
ipv4: "IPv4 address",
|
||||
ipv6: "IPv6 address",
|
||||
mac: "MAC address",
|
||||
cidrv4: "IPv4 range",
|
||||
cidrv6: "IPv6 range",
|
||||
base64: "base64-encoded string",
|
||||
base64url: "base64url-encoded string",
|
||||
json_string: "JSON string",
|
||||
e164: "E.164 number",
|
||||
currency_code: "currency code",
|
||||
credit_card: "credit card number",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "input",
|
||||
};
|
||||
// type names: missing keys = do not translate (use raw value via ?? fallback)
|
||||
const TypeDictionary = {
|
||||
// Compatibility: "nan" -> "NaN" for display
|
||||
nan: "NaN",
|
||||
// All other type names omitted - they fall back to raw values via ?? operator
|
||||
};
|
||||
function getTypeName(type, input) {
|
||||
if (type === "number" && typeof input === "number" && !Number.isFinite(input)) {
|
||||
return String(input);
|
||||
}
|
||||
return TypeDictionary[type] ?? type;
|
||||
}
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = getTypeName(issue.expected);
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = getTypeName(receivedType, issue.input);
|
||||
return `Invalid input: expected ${expected}, received ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Invalid input: expected ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Invalid option: expected one of ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
||||
return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `Invalid string: must start with "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `Invalid string: must end with "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Invalid string: must include "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Invalid string: must match pattern ${_issue.pattern}`;
|
||||
return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Invalid number: must be a multiple of ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Invalid key in ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
|
||||
const opts = issue.options.map((o) => `'${o}'`).join(" | ");
|
||||
return `Invalid discriminator value. Expected ${opts}`;
|
||||
}
|
||||
if (issue.inclusive === false) {
|
||||
return "Invalid input: more than one option matched";
|
||||
}
|
||||
return "Invalid input";
|
||||
case "invalid_element":
|
||||
return `Invalid value in ${issue.origin}`;
|
||||
default:
|
||||
return `Invalid input`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "characters", verb: "to have" },
|
||||
file: { unit: "bytes", verb: "to have" },
|
||||
array: { unit: "items", verb: "to have" },
|
||||
set: { unit: "items", verb: "to have" },
|
||||
map: { unit: "entries", verb: "to have" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "input",
|
||||
email: "email address",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO datetime",
|
||||
date: "ISO date",
|
||||
time: "ISO time",
|
||||
duration: "ISO duration",
|
||||
ipv4: "IPv4 address",
|
||||
ipv6: "IPv6 address",
|
||||
mac: "MAC address",
|
||||
cidrv4: "IPv4 range",
|
||||
cidrv6: "IPv6 range",
|
||||
base64: "base64-encoded string",
|
||||
base64url: "base64url-encoded string",
|
||||
json_string: "JSON string",
|
||||
e164: "E.164 number",
|
||||
currency_code: "currency code",
|
||||
credit_card: "credit card number",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "input",
|
||||
};
|
||||
// type names: missing keys = do not translate (use raw value via ?? fallback)
|
||||
const TypeDictionary = {
|
||||
// Compatibility: "nan" -> "NaN" for display
|
||||
nan: "NaN",
|
||||
// All other type names omitted - they fall back to raw values via ?? operator
|
||||
};
|
||||
function getTypeName(type, input) {
|
||||
if (type === "number" && typeof input === "number" && !Number.isFinite(input)) {
|
||||
return String(input);
|
||||
}
|
||||
return TypeDictionary[type] ?? type;
|
||||
}
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = getTypeName(issue.expected);
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = getTypeName(receivedType, issue.input);
|
||||
return `Invalid input: expected ${expected}, received ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Invalid input: expected ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Invalid option: expected one of ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
||||
return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `Invalid string: must start with "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `Invalid string: must end with "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Invalid string: must include "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Invalid string: must match pattern ${_issue.pattern}`;
|
||||
return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Invalid number: must be a multiple of ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Invalid key in ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
|
||||
const opts = issue.options.map((o) => `'${o}'`).join(" | ");
|
||||
return `Invalid discriminator value. Expected ${opts}`;
|
||||
}
|
||||
if (issue.inclusive === false) {
|
||||
return "Invalid input: more than one option matched";
|
||||
}
|
||||
return "Invalid input";
|
||||
case "invalid_element":
|
||||
return `Invalid value in ${issue.origin}`;
|
||||
default:
|
||||
return `Invalid input`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "karaktrojn", verb: "havi" },
|
||||
file: { unit: "bajtojn", verb: "havi" },
|
||||
array: { unit: "elementojn", verb: "havi" },
|
||||
set: { unit: "elementojn", verb: "havi" },
|
||||
map: { unit: "elementojn", verb: "havi" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "enigo",
|
||||
email: "retadreso",
|
||||
url: "URL",
|
||||
emoji: "emoĝio",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO-datotempo",
|
||||
date: "ISO-dato",
|
||||
time: "ISO-tempo",
|
||||
duration: "ISO-daŭro",
|
||||
ipv4: "IPv4-adreso",
|
||||
ipv6: "IPv6-adreso",
|
||||
mac: "MAC-adreso",
|
||||
cidrv4: "IPv4-rango",
|
||||
cidrv6: "IPv6-rango",
|
||||
base64: "64-ume kodita karaktraro",
|
||||
base64url: "URL-64-ume kodita karaktraro",
|
||||
json_string: "JSON-karaktraro",
|
||||
e164: "E.164-nombro",
|
||||
credit_card: "kreditkarta numero",
|
||||
currency_code: "valuta kodo",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "enigo",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "nombro",
|
||||
array: "tabelo",
|
||||
null: "senvalora",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Nevalida enigo: atendiĝis instanceof ${issue.expected}, riceviĝis ${received}`;
|
||||
}
|
||||
return `Nevalida enigo: atendiĝis ${expected}, riceviĝis ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Nevalida enigo: atendiĝis ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Nevalida opcio: atendiĝis unu el ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Tro granda: atendiĝis ke ${issue.origin ?? "valoro"} havu ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementojn"}`;
|
||||
return `Tro granda: atendiĝis ke ${issue.origin ?? "valoro"} havu ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Tro malgranda: atendiĝis ke ${issue.origin} havu ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Tro malgranda: atendiĝis ke ${issue.origin} estu ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Nevalida karaktraro: devas komenciĝi per "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Nevalida karaktraro: devas finiĝi per "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Nevalida karaktraro: devas inkluzivi "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Nevalida karaktraro: devas kongrui kun la modelo ${_issue.pattern}`;
|
||||
return `Nevalida ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Nevalida nombro: devas esti oblo de ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Nekonata${issue.keys.length > 1 ? "j" : ""} ŝlosilo${issue.keys.length > 1 ? "j" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Nevalida ŝlosilo en ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Nevalida enigo";
|
||||
case "invalid_element":
|
||||
return `Nevalida valoro en ${issue.origin}`;
|
||||
default:
|
||||
return `Nevalida enigo`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "karaktrojn", verb: "havi" },
|
||||
file: { unit: "bajtojn", verb: "havi" },
|
||||
array: { unit: "elementojn", verb: "havi" },
|
||||
set: { unit: "elementojn", verb: "havi" },
|
||||
map: { unit: "elementojn", verb: "havi" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "enigo",
|
||||
email: "retadreso",
|
||||
url: "URL",
|
||||
emoji: "emoĝio",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO-datotempo",
|
||||
date: "ISO-dato",
|
||||
time: "ISO-tempo",
|
||||
duration: "ISO-daŭro",
|
||||
ipv4: "IPv4-adreso",
|
||||
ipv6: "IPv6-adreso",
|
||||
mac: "MAC-adreso",
|
||||
cidrv4: "IPv4-rango",
|
||||
cidrv6: "IPv6-rango",
|
||||
base64: "64-ume kodita karaktraro",
|
||||
base64url: "URL-64-ume kodita karaktraro",
|
||||
json_string: "JSON-karaktraro",
|
||||
e164: "E.164-nombro",
|
||||
credit_card: "kreditkarta numero",
|
||||
currency_code: "valuta kodo",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "enigo",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "nombro",
|
||||
array: "tabelo",
|
||||
null: "senvalora",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Nevalida enigo: atendiĝis instanceof ${issue.expected}, riceviĝis ${received}`;
|
||||
}
|
||||
return `Nevalida enigo: atendiĝis ${expected}, riceviĝis ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Nevalida enigo: atendiĝis ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Nevalida opcio: atendiĝis unu el ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Tro granda: atendiĝis ke ${issue.origin ?? "valoro"} havu ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementojn"}`;
|
||||
return `Tro granda: atendiĝis ke ${issue.origin ?? "valoro"} havu ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Tro malgranda: atendiĝis ke ${issue.origin} havu ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Tro malgranda: atendiĝis ke ${issue.origin} estu ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Nevalida karaktraro: devas komenciĝi per "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Nevalida karaktraro: devas finiĝi per "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Nevalida karaktraro: devas inkluzivi "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Nevalida karaktraro: devas kongrui kun la modelo ${_issue.pattern}`;
|
||||
return `Nevalida ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Nevalida nombro: devas esti oblo de ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Nekonata${issue.keys.length > 1 ? "j" : ""} ŝlosilo${issue.keys.length > 1 ? "j" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Nevalida ŝlosilo en ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Nevalida enigo";
|
||||
case "invalid_element":
|
||||
return `Nevalida valoro en ${issue.origin}`;
|
||||
default:
|
||||
return `Nevalida enigo`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "caracteres", verb: "tener" },
|
||||
file: { unit: "bytes", verb: "tener" },
|
||||
array: { unit: "elementos", verb: "tener" },
|
||||
set: { unit: "elementos", verb: "tener" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "entrada",
|
||||
email: "dirección de correo electrónico",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "fecha y hora ISO",
|
||||
date: "fecha ISO",
|
||||
time: "hora ISO",
|
||||
duration: "duración ISO",
|
||||
ipv4: "dirección IPv4",
|
||||
ipv6: "dirección IPv6",
|
||||
mac: "dirección MAC",
|
||||
cidrv4: "rango IPv4",
|
||||
cidrv6: "rango IPv6",
|
||||
base64: "cadena codificada en base64",
|
||||
base64url: "URL codificada en base64",
|
||||
json_string: "cadena JSON",
|
||||
e164: "número E.164",
|
||||
credit_card: "número de tarjeta de crédito",
|
||||
currency_code: "código de moneda",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "entrada",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
string: "texto",
|
||||
number: "número",
|
||||
boolean: "booleano",
|
||||
array: "arreglo",
|
||||
object: "objeto",
|
||||
set: "conjunto",
|
||||
file: "archivo",
|
||||
date: "fecha",
|
||||
bigint: "número grande",
|
||||
symbol: "símbolo",
|
||||
undefined: "indefinido",
|
||||
null: "nulo",
|
||||
function: "función",
|
||||
map: "mapa",
|
||||
record: "registro",
|
||||
tuple: "tupla",
|
||||
enum: "enumeración",
|
||||
union: "unión",
|
||||
literal: "literal",
|
||||
promise: "promesa",
|
||||
void: "vacío",
|
||||
never: "nunca",
|
||||
unknown: "desconocido",
|
||||
any: "cualquiera",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Entrada inválida: se esperaba instanceof ${issue.expected}, recibido ${received}`;
|
||||
}
|
||||
return `Entrada inválida: se esperaba ${expected}, recibido ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Entrada inválida: se esperaba ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Opción inválida: se esperaba una de ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
const origin = TypeDictionary[issue.origin] ?? issue.origin;
|
||||
if (sizing)
|
||||
return `Demasiado grande: se esperaba que ${origin ?? "valor"} tuviera ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementos"}`;
|
||||
return `Demasiado grande: se esperaba que ${origin ?? "valor"} fuera ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
const origin = TypeDictionary[issue.origin] ?? issue.origin;
|
||||
if (sizing) {
|
||||
return `Demasiado pequeño: se esperaba que ${origin} tuviera ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Demasiado pequeño: se esperaba que ${origin} fuera ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Cadena inválida: debe comenzar con "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Cadena inválida: debe terminar en "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Cadena inválida: debe incluir "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Cadena inválida: debe coincidir con el patrón ${_issue.pattern}`;
|
||||
return `Inválido ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Número inválido: debe ser múltiplo de ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Llave${issue.keys.length > 1 ? "s" : ""} desconocida${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Llave inválida en ${TypeDictionary[issue.origin] ?? issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Entrada inválida";
|
||||
case "invalid_element":
|
||||
return `Valor inválido en ${TypeDictionary[issue.origin] ?? issue.origin}`;
|
||||
default:
|
||||
return `Entrada inválida`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "caracteres", verb: "tener" },
|
||||
file: { unit: "bytes", verb: "tener" },
|
||||
array: { unit: "elementos", verb: "tener" },
|
||||
set: { unit: "elementos", verb: "tener" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "entrada",
|
||||
email: "dirección de correo electrónico",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "fecha y hora ISO",
|
||||
date: "fecha ISO",
|
||||
time: "hora ISO",
|
||||
duration: "duración ISO",
|
||||
ipv4: "dirección IPv4",
|
||||
ipv6: "dirección IPv6",
|
||||
mac: "dirección MAC",
|
||||
cidrv4: "rango IPv4",
|
||||
cidrv6: "rango IPv6",
|
||||
base64: "cadena codificada en base64",
|
||||
base64url: "URL codificada en base64",
|
||||
json_string: "cadena JSON",
|
||||
e164: "número E.164",
|
||||
credit_card: "número de tarjeta de crédito",
|
||||
currency_code: "código de moneda",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "entrada",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
string: "texto",
|
||||
number: "número",
|
||||
boolean: "booleano",
|
||||
array: "arreglo",
|
||||
object: "objeto",
|
||||
set: "conjunto",
|
||||
file: "archivo",
|
||||
date: "fecha",
|
||||
bigint: "número grande",
|
||||
symbol: "símbolo",
|
||||
undefined: "indefinido",
|
||||
null: "nulo",
|
||||
function: "función",
|
||||
map: "mapa",
|
||||
record: "registro",
|
||||
tuple: "tupla",
|
||||
enum: "enumeración",
|
||||
union: "unión",
|
||||
literal: "literal",
|
||||
promise: "promesa",
|
||||
void: "vacío",
|
||||
never: "nunca",
|
||||
unknown: "desconocido",
|
||||
any: "cualquiera",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Entrada inválida: se esperaba instanceof ${issue.expected}, recibido ${received}`;
|
||||
}
|
||||
return `Entrada inválida: se esperaba ${expected}, recibido ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Entrada inválida: se esperaba ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Opción inválida: se esperaba una de ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
const origin = TypeDictionary[issue.origin] ?? issue.origin;
|
||||
if (sizing)
|
||||
return `Demasiado grande: se esperaba que ${origin ?? "valor"} tuviera ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementos"}`;
|
||||
return `Demasiado grande: se esperaba que ${origin ?? "valor"} fuera ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
const origin = TypeDictionary[issue.origin] ?? issue.origin;
|
||||
if (sizing) {
|
||||
return `Demasiado pequeño: se esperaba que ${origin} tuviera ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Demasiado pequeño: se esperaba que ${origin} fuera ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Cadena inválida: debe comenzar con "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Cadena inválida: debe terminar en "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Cadena inválida: debe incluir "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Cadena inválida: debe coincidir con el patrón ${_issue.pattern}`;
|
||||
return `Inválido ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Número inválido: debe ser múltiplo de ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Llave${issue.keys.length > 1 ? "s" : ""} desconocida${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Llave inválida en ${TypeDictionary[issue.origin] ?? issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Entrada inválida";
|
||||
case "invalid_element":
|
||||
return `Valor inválido en ${TypeDictionary[issue.origin] ?? issue.origin}`;
|
||||
default:
|
||||
return `Entrada inválida`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "کاراکتر", verb: "داشته باشد" },
|
||||
file: { unit: "بایت", verb: "داشته باشد" },
|
||||
array: { unit: "آیتم", verb: "داشته باشد" },
|
||||
set: { unit: "آیتم", verb: "داشته باشد" },
|
||||
map: { unit: "آیتم", verb: "داشته باشد" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "ورودی",
|
||||
email: "آدرس ایمیل",
|
||||
url: "URL",
|
||||
emoji: "ایموجی",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "تاریخ و زمان ایزو",
|
||||
date: "تاریخ ایزو",
|
||||
time: "زمان ایزو",
|
||||
duration: "مدت زمان ایزو",
|
||||
ipv4: "IPv4 آدرس",
|
||||
ipv6: "IPv6 آدرس",
|
||||
mac: "MAC آدرس",
|
||||
cidrv4: "IPv4 دامنه",
|
||||
cidrv6: "IPv6 دامنه",
|
||||
base64: "base64-encoded رشته",
|
||||
base64url: "base64url-encoded رشته",
|
||||
json_string: "JSON رشته",
|
||||
e164: "E.164 عدد",
|
||||
credit_card: "شماره کارت اعتباری",
|
||||
currency_code: "کد ارز",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "ورودی",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "عدد",
|
||||
array: "آرایه",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `ورودی نامعتبر: میبایست instanceof ${issue.expected} میبود، ${received} دریافت شد`;
|
||||
}
|
||||
return `ورودی نامعتبر: میبایست ${expected} میبود، ${received} دریافت شد`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1) {
|
||||
return `ورودی نامعتبر: میبایست ${util.stringifyPrimitive(issue.values[0])} میبود`;
|
||||
}
|
||||
return `گزینه نامعتبر: میبایست یکی از ${util.joinValues(issue.values, "|")} میبود`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `خیلی بزرگ: ${issue.origin ?? "مقدار"} باید ${adj}${issue.maximum.toString()} ${sizing.unit ?? "عنصر"} باشد`;
|
||||
}
|
||||
return `خیلی بزرگ: ${issue.origin ?? "مقدار"} باید ${adj}${issue.maximum.toString()} باشد`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `خیلی کوچک: ${issue.origin} باید ${adj}${issue.minimum.toString()} ${sizing.unit} باشد`;
|
||||
}
|
||||
return `خیلی کوچک: ${issue.origin} باید ${adj}${issue.minimum.toString()} باشد`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `رشته نامعتبر: باید با "${_issue.prefix}" شروع شود`;
|
||||
}
|
||||
if (_issue.format === "ends_with") {
|
||||
return `رشته نامعتبر: باید با "${_issue.suffix}" تمام شود`;
|
||||
}
|
||||
if (_issue.format === "includes") {
|
||||
return `رشته نامعتبر: باید شامل "${_issue.includes}" باشد`;
|
||||
}
|
||||
if (_issue.format === "regex") {
|
||||
return `رشته نامعتبر: باید با الگوی ${_issue.pattern} مطابقت داشته باشد`;
|
||||
}
|
||||
return `${FormatDictionary[_issue.format] ?? issue.format} نامعتبر`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `عدد نامعتبر: باید مضرب ${issue.divisor} باشد`;
|
||||
case "unrecognized_keys":
|
||||
return `کلید${issue.keys.length > 1 ? "های" : ""} ناشناس: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `کلید ناشناس در ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return `ورودی نامعتبر`;
|
||||
case "invalid_element":
|
||||
return `مقدار نامعتبر در ${issue.origin}`;
|
||||
default:
|
||||
return `ورودی نامعتبر`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "کاراکتر", verb: "داشته باشد" },
|
||||
file: { unit: "بایت", verb: "داشته باشد" },
|
||||
array: { unit: "آیتم", verb: "داشته باشد" },
|
||||
set: { unit: "آیتم", verb: "داشته باشد" },
|
||||
map: { unit: "آیتم", verb: "داشته باشد" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "ورودی",
|
||||
email: "آدرس ایمیل",
|
||||
url: "URL",
|
||||
emoji: "ایموجی",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "تاریخ و زمان ایزو",
|
||||
date: "تاریخ ایزو",
|
||||
time: "زمان ایزو",
|
||||
duration: "مدت زمان ایزو",
|
||||
ipv4: "IPv4 آدرس",
|
||||
ipv6: "IPv6 آدرس",
|
||||
mac: "MAC آدرس",
|
||||
cidrv4: "IPv4 دامنه",
|
||||
cidrv6: "IPv6 دامنه",
|
||||
base64: "base64-encoded رشته",
|
||||
base64url: "base64url-encoded رشته",
|
||||
json_string: "JSON رشته",
|
||||
e164: "E.164 عدد",
|
||||
credit_card: "شماره کارت اعتباری",
|
||||
currency_code: "کد ارز",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "ورودی",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "عدد",
|
||||
array: "آرایه",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `ورودی نامعتبر: میبایست instanceof ${issue.expected} میبود، ${received} دریافت شد`;
|
||||
}
|
||||
return `ورودی نامعتبر: میبایست ${expected} میبود، ${received} دریافت شد`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1) {
|
||||
return `ورودی نامعتبر: میبایست ${util.stringifyPrimitive(issue.values[0])} میبود`;
|
||||
}
|
||||
return `گزینه نامعتبر: میبایست یکی از ${util.joinValues(issue.values, "|")} میبود`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `خیلی بزرگ: ${issue.origin ?? "مقدار"} باید ${adj}${issue.maximum.toString()} ${sizing.unit ?? "عنصر"} باشد`;
|
||||
}
|
||||
return `خیلی بزرگ: ${issue.origin ?? "مقدار"} باید ${adj}${issue.maximum.toString()} باشد`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `خیلی کوچک: ${issue.origin} باید ${adj}${issue.minimum.toString()} ${sizing.unit} باشد`;
|
||||
}
|
||||
return `خیلی کوچک: ${issue.origin} باید ${adj}${issue.minimum.toString()} باشد`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `رشته نامعتبر: باید با "${_issue.prefix}" شروع شود`;
|
||||
}
|
||||
if (_issue.format === "ends_with") {
|
||||
return `رشته نامعتبر: باید با "${_issue.suffix}" تمام شود`;
|
||||
}
|
||||
if (_issue.format === "includes") {
|
||||
return `رشته نامعتبر: باید شامل "${_issue.includes}" باشد`;
|
||||
}
|
||||
if (_issue.format === "regex") {
|
||||
return `رشته نامعتبر: باید با الگوی ${_issue.pattern} مطابقت داشته باشد`;
|
||||
}
|
||||
return `${FormatDictionary[_issue.format] ?? issue.format} نامعتبر`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `عدد نامعتبر: باید مضرب ${issue.divisor} باشد`;
|
||||
case "unrecognized_keys":
|
||||
return `کلید${issue.keys.length > 1 ? "های" : ""} ناشناس: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `کلید ناشناس در ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return `ورودی نامعتبر`;
|
||||
case "invalid_element":
|
||||
return `مقدار نامعتبر در ${issue.origin}`;
|
||||
default:
|
||||
return `ورودی نامعتبر`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "merkkiä", subject: "merkkijonon" },
|
||||
file: { unit: "tavua", subject: "tiedoston" },
|
||||
array: { unit: "alkiota", subject: "listan" },
|
||||
set: { unit: "alkiota", subject: "joukon" },
|
||||
map: { unit: "alkiota", subject: "kuvauksen" },
|
||||
number: { unit: "", subject: "luvun" },
|
||||
bigint: { unit: "", subject: "suuren kokonaisluvun" },
|
||||
int: { unit: "", subject: "kokonaisluvun" },
|
||||
date: { unit: "", subject: "päivämäärän" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "säännöllinen lauseke",
|
||||
email: "sähköpostiosoite",
|
||||
url: "URL-osoite",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO-aikaleima",
|
||||
date: "ISO-päivämäärä",
|
||||
time: "ISO-aika",
|
||||
duration: "ISO-kesto",
|
||||
ipv4: "IPv4-osoite",
|
||||
ipv6: "IPv6-osoite",
|
||||
mac: "MAC-osoite",
|
||||
cidrv4: "IPv4-alue",
|
||||
cidrv6: "IPv6-alue",
|
||||
base64: "base64-koodattu merkkijono",
|
||||
base64url: "base64url-koodattu merkkijono",
|
||||
json_string: "JSON-merkkijono",
|
||||
e164: "E.164-luku",
|
||||
credit_card: "luottokortin numero",
|
||||
currency_code: "valuuttakoodi",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "templaattimerkkijono",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Virheellinen tyyppi: odotettiin instanceof ${issue.expected}, oli ${received}`;
|
||||
}
|
||||
return `Virheellinen tyyppi: odotettiin ${expected}, oli ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Virheellinen syöte: täytyy olla ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Virheellinen valinta: täytyy olla yksi seuraavista: ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Liian suuri: ${sizing.subject} täytyy olla ${adj}${issue.maximum.toString()} ${sizing.unit}`.trim();
|
||||
}
|
||||
return `Liian suuri: arvon täytyy olla ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Liian pieni: ${sizing.subject} täytyy olla ${adj}${issue.minimum.toString()} ${sizing.unit}`.trim();
|
||||
}
|
||||
return `Liian pieni: arvon täytyy olla ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Virheellinen syöte: täytyy alkaa "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Virheellinen syöte: täytyy loppua "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Virheellinen syöte: täytyy sisältää "${_issue.includes}"`;
|
||||
if (_issue.format === "regex") {
|
||||
return `Virheellinen syöte: täytyy vastata säännöllistä lauseketta ${_issue.pattern}`;
|
||||
}
|
||||
return `Virheellinen ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Virheellinen luku: täytyy olla luvun ${issue.divisor} monikerta`;
|
||||
case "unrecognized_keys":
|
||||
return `${issue.keys.length > 1 ? "Tuntemattomat avaimet" : "Tuntematon avain"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return "Virheellinen avain tietueessa";
|
||||
case "invalid_union":
|
||||
return "Virheellinen unioni";
|
||||
case "invalid_element":
|
||||
return "Virheellinen arvo joukossa";
|
||||
default:
|
||||
return `Virheellinen syöte`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "merkkiä", subject: "merkkijonon" },
|
||||
file: { unit: "tavua", subject: "tiedoston" },
|
||||
array: { unit: "alkiota", subject: "listan" },
|
||||
set: { unit: "alkiota", subject: "joukon" },
|
||||
map: { unit: "alkiota", subject: "kuvauksen" },
|
||||
number: { unit: "", subject: "luvun" },
|
||||
bigint: { unit: "", subject: "suuren kokonaisluvun" },
|
||||
int: { unit: "", subject: "kokonaisluvun" },
|
||||
date: { unit: "", subject: "päivämäärän" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "säännöllinen lauseke",
|
||||
email: "sähköpostiosoite",
|
||||
url: "URL-osoite",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO-aikaleima",
|
||||
date: "ISO-päivämäärä",
|
||||
time: "ISO-aika",
|
||||
duration: "ISO-kesto",
|
||||
ipv4: "IPv4-osoite",
|
||||
ipv6: "IPv6-osoite",
|
||||
mac: "MAC-osoite",
|
||||
cidrv4: "IPv4-alue",
|
||||
cidrv6: "IPv6-alue",
|
||||
base64: "base64-koodattu merkkijono",
|
||||
base64url: "base64url-koodattu merkkijono",
|
||||
json_string: "JSON-merkkijono",
|
||||
e164: "E.164-luku",
|
||||
credit_card: "luottokortin numero",
|
||||
currency_code: "valuuttakoodi",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "templaattimerkkijono",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Virheellinen tyyppi: odotettiin instanceof ${issue.expected}, oli ${received}`;
|
||||
}
|
||||
return `Virheellinen tyyppi: odotettiin ${expected}, oli ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Virheellinen syöte: täytyy olla ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Virheellinen valinta: täytyy olla yksi seuraavista: ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Liian suuri: ${sizing.subject} täytyy olla ${adj}${issue.maximum.toString()} ${sizing.unit}`.trim();
|
||||
}
|
||||
return `Liian suuri: arvon täytyy olla ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Liian pieni: ${sizing.subject} täytyy olla ${adj}${issue.minimum.toString()} ${sizing.unit}`.trim();
|
||||
}
|
||||
return `Liian pieni: arvon täytyy olla ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Virheellinen syöte: täytyy alkaa "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Virheellinen syöte: täytyy loppua "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Virheellinen syöte: täytyy sisältää "${_issue.includes}"`;
|
||||
if (_issue.format === "regex") {
|
||||
return `Virheellinen syöte: täytyy vastata säännöllistä lauseketta ${_issue.pattern}`;
|
||||
}
|
||||
return `Virheellinen ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Virheellinen luku: täytyy olla luvun ${issue.divisor} monikerta`;
|
||||
case "unrecognized_keys":
|
||||
return `${issue.keys.length > 1 ? "Tuntemattomat avaimet" : "Tuntematon avain"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return "Virheellinen avain tietueessa";
|
||||
case "invalid_union":
|
||||
return "Virheellinen unioni";
|
||||
case "invalid_element":
|
||||
return "Virheellinen arvo joukossa";
|
||||
default:
|
||||
return `Virheellinen syöte`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "caractères", verb: "avoir" },
|
||||
file: { unit: "octets", verb: "avoir" },
|
||||
array: { unit: "éléments", verb: "avoir" },
|
||||
set: { unit: "éléments", verb: "avoir" },
|
||||
map: { unit: "éléments", verb: "avoir" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "entrée",
|
||||
email: "adresse courriel",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "date-heure ISO",
|
||||
date: "date ISO",
|
||||
time: "heure ISO",
|
||||
duration: "durée ISO",
|
||||
ipv4: "adresse IPv4",
|
||||
ipv6: "adresse IPv6",
|
||||
mac: "adresse MAC",
|
||||
cidrv4: "plage IPv4",
|
||||
cidrv6: "plage IPv6",
|
||||
base64: "chaîne encodée en base64",
|
||||
base64url: "chaîne encodée en base64url",
|
||||
json_string: "chaîne JSON",
|
||||
e164: "numéro E.164",
|
||||
credit_card: "numéro de carte de crédit",
|
||||
currency_code: "code de devise",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "entrée",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Entrée invalide : attendu instanceof ${issue.expected}, reçu ${received}`;
|
||||
}
|
||||
return `Entrée invalide : attendu ${expected}, reçu ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Entrée invalide : attendu ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Option invalide : attendu l'une des valeurs suivantes ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "≤" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Trop grand : attendu que ${issue.origin ?? "la valeur"} ait ${adj}${issue.maximum.toString()} ${sizing.unit}`;
|
||||
return `Trop grand : attendu que ${issue.origin ?? "la valeur"} soit ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? "≥" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Trop petit : attendu que ${issue.origin} ait ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Trop petit : attendu que ${issue.origin} soit ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `Chaîne invalide : doit commencer par "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `Chaîne invalide : doit se terminer par "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Chaîne invalide : doit inclure "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Chaîne invalide : doit correspondre au motif ${_issue.pattern}`;
|
||||
return `${FormatDictionary[_issue.format] ?? issue.format} invalide`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Nombre invalide : doit être un multiple de ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Clé${issue.keys.length > 1 ? "s" : ""} non reconnue${issue.keys.length > 1 ? "s" : ""} : ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Clé invalide dans ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Entrée invalide";
|
||||
case "invalid_element":
|
||||
return `Valeur invalide dans ${issue.origin}`;
|
||||
default:
|
||||
return `Entrée invalide`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "caractères", verb: "avoir" },
|
||||
file: { unit: "octets", verb: "avoir" },
|
||||
array: { unit: "éléments", verb: "avoir" },
|
||||
set: { unit: "éléments", verb: "avoir" },
|
||||
map: { unit: "éléments", verb: "avoir" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "entrée",
|
||||
email: "adresse courriel",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "date-heure ISO",
|
||||
date: "date ISO",
|
||||
time: "heure ISO",
|
||||
duration: "durée ISO",
|
||||
ipv4: "adresse IPv4",
|
||||
ipv6: "adresse IPv6",
|
||||
mac: "adresse MAC",
|
||||
cidrv4: "plage IPv4",
|
||||
cidrv6: "plage IPv6",
|
||||
base64: "chaîne encodée en base64",
|
||||
base64url: "chaîne encodée en base64url",
|
||||
json_string: "chaîne JSON",
|
||||
e164: "numéro E.164",
|
||||
credit_card: "numéro de carte de crédit",
|
||||
currency_code: "code de devise",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "entrée",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Entrée invalide : attendu instanceof ${issue.expected}, reçu ${received}`;
|
||||
}
|
||||
return `Entrée invalide : attendu ${expected}, reçu ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Entrée invalide : attendu ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Option invalide : attendu l'une des valeurs suivantes ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "≤" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Trop grand : attendu que ${issue.origin ?? "la valeur"} ait ${adj}${issue.maximum.toString()} ${sizing.unit}`;
|
||||
return `Trop grand : attendu que ${issue.origin ?? "la valeur"} soit ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? "≥" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Trop petit : attendu que ${issue.origin} ait ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Trop petit : attendu que ${issue.origin} soit ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `Chaîne invalide : doit commencer par "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `Chaîne invalide : doit se terminer par "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Chaîne invalide : doit inclure "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Chaîne invalide : doit correspondre au motif ${_issue.pattern}`;
|
||||
return `${FormatDictionary[_issue.format] ?? issue.format} invalide`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Nombre invalide : doit être un multiple de ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Clé${issue.keys.length > 1 ? "s" : ""} non reconnue${issue.keys.length > 1 ? "s" : ""} : ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Clé invalide dans ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Entrée invalide";
|
||||
case "invalid_element":
|
||||
return `Valeur invalide dans ${issue.origin}`;
|
||||
default:
|
||||
return `Entrée invalide`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "caractères", verb: "avoir" },
|
||||
file: { unit: "octets", verb: "avoir" },
|
||||
array: { unit: "éléments", verb: "avoir" },
|
||||
set: { unit: "éléments", verb: "avoir" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "expression régulière",
|
||||
email: "adresse e-mail",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "date et heure ISO",
|
||||
date: "date ISO",
|
||||
time: "heure ISO",
|
||||
duration: "durée ISO",
|
||||
ipv4: "adresse IPv4",
|
||||
ipv6: "adresse IPv6",
|
||||
mac: "adresse MAC",
|
||||
cidrv4: "plage IPv4",
|
||||
cidrv6: "plage IPv6",
|
||||
base64: "chaîne de caractères encodée en base64",
|
||||
base64url: "chaîne de caractères encodée en base64url",
|
||||
json_string: "chaîne de caractères JSON",
|
||||
e164: "numéro au format E.164",
|
||||
credit_card: "numéro de carte de crédit",
|
||||
currency_code: "code de devise",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "entrée",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
string: "chaîne de caractères",
|
||||
number: "nombre",
|
||||
int: "entier",
|
||||
boolean: "booléen",
|
||||
bigint: "grand entier",
|
||||
symbol: "symbole",
|
||||
undefined: "indéfini",
|
||||
null: "null",
|
||||
never: "jamais",
|
||||
void: "vide",
|
||||
date: "date",
|
||||
array: "tableau",
|
||||
object: "objet",
|
||||
tuple: "tuple",
|
||||
record: "record",
|
||||
map: "map",
|
||||
set: "ensemble",
|
||||
file: "fichier",
|
||||
nonoptional: "non optionnel",
|
||||
nan: "NaN",
|
||||
function: "fonction",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Entrée invalide : instance de ${issue.expected} attendu, ${received} reçu`;
|
||||
}
|
||||
return `Entrée invalide : ${expected} attendu, ${received} reçu`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Entrée invalide : ${util.stringifyPrimitive(issue.values[0])} attendu`;
|
||||
return `Option invalide : une valeur parmi ${util.joinValues(issue.values, "|")} attendue`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Trop grand : ${TypeDictionary[issue.origin] ?? "valeur"} doit ${sizing.verb} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "élément(s)"}`;
|
||||
return `Trop grand : ${TypeDictionary[issue.origin] ?? "valeur"} doit être ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Trop petit : ${TypeDictionary[issue.origin] ?? "valeur"} doit ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
return `Trop petit : ${TypeDictionary[issue.origin] ?? "valeur"} doit être ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Chaîne de caractères invalide : doit commencer par "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Chaîne de caractères invalide : doit se terminer par "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Chaîne de caractères invalide : doit inclure "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Chaîne de caractères invalide : doit correspondre au motif ${_issue.pattern}`;
|
||||
return `${FormatDictionary[_issue.format] ?? issue.format} invalide`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Nombre invalide : doit être un multiple de ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Clé${issue.keys.length > 1 ? "s" : ""} non reconnue${issue.keys.length > 1 ? "s" : ""} : ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Clé invalide dans ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Entrée invalide";
|
||||
case "invalid_element":
|
||||
return `Valeur invalide dans ${issue.origin}`;
|
||||
default:
|
||||
return `Entrée invalide`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "caractères", verb: "avoir" },
|
||||
file: { unit: "octets", verb: "avoir" },
|
||||
array: { unit: "éléments", verb: "avoir" },
|
||||
set: { unit: "éléments", verb: "avoir" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "expression régulière",
|
||||
email: "adresse e-mail",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "date et heure ISO",
|
||||
date: "date ISO",
|
||||
time: "heure ISO",
|
||||
duration: "durée ISO",
|
||||
ipv4: "adresse IPv4",
|
||||
ipv6: "adresse IPv6",
|
||||
mac: "adresse MAC",
|
||||
cidrv4: "plage IPv4",
|
||||
cidrv6: "plage IPv6",
|
||||
base64: "chaîne de caractères encodée en base64",
|
||||
base64url: "chaîne de caractères encodée en base64url",
|
||||
json_string: "chaîne de caractères JSON",
|
||||
e164: "numéro au format E.164",
|
||||
credit_card: "numéro de carte de crédit",
|
||||
currency_code: "code de devise",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "entrée",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
string: "chaîne de caractères",
|
||||
number: "nombre",
|
||||
int: "entier",
|
||||
boolean: "booléen",
|
||||
bigint: "grand entier",
|
||||
symbol: "symbole",
|
||||
undefined: "indéfini",
|
||||
null: "null",
|
||||
never: "jamais",
|
||||
void: "vide",
|
||||
date: "date",
|
||||
array: "tableau",
|
||||
object: "objet",
|
||||
tuple: "tuple",
|
||||
record: "record",
|
||||
map: "map",
|
||||
set: "ensemble",
|
||||
file: "fichier",
|
||||
nonoptional: "non optionnel",
|
||||
nan: "NaN",
|
||||
function: "fonction",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Entrée invalide : instance de ${issue.expected} attendu, ${received} reçu`;
|
||||
}
|
||||
return `Entrée invalide : ${expected} attendu, ${received} reçu`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Entrée invalide : ${util.stringifyPrimitive(issue.values[0])} attendu`;
|
||||
return `Option invalide : une valeur parmi ${util.joinValues(issue.values, "|")} attendue`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Trop grand : ${TypeDictionary[issue.origin] ?? "valeur"} doit ${sizing.verb} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "élément(s)"}`;
|
||||
return `Trop grand : ${TypeDictionary[issue.origin] ?? "valeur"} doit être ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Trop petit : ${TypeDictionary[issue.origin] ?? "valeur"} doit ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
return `Trop petit : ${TypeDictionary[issue.origin] ?? "valeur"} doit être ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Chaîne de caractères invalide : doit commencer par "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Chaîne de caractères invalide : doit se terminer par "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Chaîne de caractères invalide : doit inclure "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Chaîne de caractères invalide : doit correspondre au motif ${_issue.pattern}`;
|
||||
return `${FormatDictionary[_issue.format] ?? issue.format} invalide`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Nombre invalide : doit être un multiple de ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Clé${issue.keys.length > 1 ? "s" : ""} non reconnue${issue.keys.length > 1 ? "s" : ""} : ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Clé invalide dans ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Entrée invalide";
|
||||
case "invalid_element":
|
||||
return `Valeur invalide dans ${issue.origin}`;
|
||||
default:
|
||||
return `Entrée invalide`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "અક્ષર", verb: "હોવા જોઈએ" },
|
||||
file: { unit: "બાયટ", verb: "હોવા જોઈએ" },
|
||||
array: { unit: "આઇટમ", verb: "હોવા જોઈએ" },
|
||||
set: { unit: "આઇટમ", verb: "હોવા જોઈએ" },
|
||||
map: { unit: "એન્ટ્રી", verb: "હોવા જોઈએ" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "ઇનપુટ",
|
||||
email: "ઈમેઇલ એડ્રેસ",
|
||||
url: "URL",
|
||||
emoji: "ઇમોજી",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO તારીખ અને સમય",
|
||||
date: "ISO તારીખ",
|
||||
time: "ISO સમય",
|
||||
duration: "ISO અવધિ",
|
||||
ipv4: "IPv4 એડ્રેસ",
|
||||
ipv6: "IPv6 એડ્રેસ",
|
||||
mac: "MAC એડ્રેસ",
|
||||
cidrv4: "IPv4 શ્રેણી",
|
||||
cidrv6: "IPv6 શ્રેણી",
|
||||
base64: "base64-એન્કોડેડ સ્ટ્રિંગ",
|
||||
base64url: "base64url-એન્કોડેડ સ્ટ્રિંગ",
|
||||
json_string: "JSON સ્ટ્રિંગ",
|
||||
e164: "E.164 નંબર",
|
||||
credit_card: "ક્રેડિટ કાર્ડ નંબર",
|
||||
currency_code: "ચલણ કોડ",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "ઇનપુટ",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
return `અમાન્ય ઇનપુટ: અપેક્ષિત ${expected}, પ્રાપ્ત ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `અમાન્ય ઇનપુટ: અપેક્ષિત ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `અમાન્ય વિકલ્પ: ${util.joinValues(issue.values, " | ")} માધ્યમથી એક અપેક્ષિત`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `ખૂબ મોટું: ${issue.origin ?? "મૂલ્ય"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "એલિમેન્ટ"} હોવા જોઈએ`;
|
||||
return `ખૂબ મોટું: ${issue.origin ?? "મૂલ્ય"} ${adj}${issue.maximum.toString()} હોવું જોઈએ`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `ખૂબ નાનું: ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} હોવા જોઈએ`;
|
||||
}
|
||||
return `ખૂબ નાનું: ${issue.origin} ${adj}${issue.minimum.toString()} હોવું જોઈએ`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `અમાન્ય સ્ટ્રિંગ: "${_issue.prefix}" થી શરૂ થવું જોઈએ`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `અમાન્ય સ્ટ્રિંગ: "${_issue.suffix}" પર સમાપ્ત થવું જોઈએ`;
|
||||
if (_issue.format === "includes")
|
||||
return `અમાન્ય સ્ટ્રિંગ: "${_issue.includes}" શામેલ હોવું જોઈએ`;
|
||||
if (_issue.format === "regex")
|
||||
return `અમાન્ય સ્ટ્રિંગ: પેટર્ન ${_issue.pattern} સાથે મેળ ખાવું જોઈએ`;
|
||||
return `અમાન્ય ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `અમાન્ય નંબર: ${issue.divisor} નો ગુણાંક હોવો જોઈએ`;
|
||||
case "unrecognized_keys":
|
||||
return `ઓળખી શકાતા નહીં તે કી${issue.keys.length > 1 ? "ઓ" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `${issue.origin} માં અમાન્ય કી`;
|
||||
case "invalid_union":
|
||||
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
|
||||
const opts = issue.options.map((o) => `'${o}'`).join(" | ");
|
||||
return `અમાન્ય ડિસ્ક્રિમિનેટર મૂલ્ય. અપેક્ષિત ${opts}`;
|
||||
}
|
||||
return "અમાન્ય ઇનપુટ";
|
||||
case "invalid_element":
|
||||
return `${issue.origin} માં અમાન્ય મૂલ્ય`;
|
||||
default:
|
||||
return "અમાન્ય ઇનપુટ";
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "અક્ષર", verb: "હોવા જોઈએ" },
|
||||
file: { unit: "બાયટ", verb: "હોવા જોઈએ" },
|
||||
array: { unit: "આઇટમ", verb: "હોવા જોઈએ" },
|
||||
set: { unit: "આઇટમ", verb: "હોવા જોઈએ" },
|
||||
map: { unit: "એન્ટ્રી", verb: "હોવા જોઈએ" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "ઇનપુટ",
|
||||
email: "ઈમેઇલ એડ્રેસ",
|
||||
url: "URL",
|
||||
emoji: "ઇમોજી",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO તારીખ અને સમય",
|
||||
date: "ISO તારીખ",
|
||||
time: "ISO સમય",
|
||||
duration: "ISO અવધિ",
|
||||
ipv4: "IPv4 એડ્રેસ",
|
||||
ipv6: "IPv6 એડ્રેસ",
|
||||
mac: "MAC એડ્રેસ",
|
||||
cidrv4: "IPv4 શ્રેણી",
|
||||
cidrv6: "IPv6 શ્રેણી",
|
||||
base64: "base64-એન્કોડેડ સ્ટ્રિંગ",
|
||||
base64url: "base64url-એન્કોડેડ સ્ટ્રિંગ",
|
||||
json_string: "JSON સ્ટ્રિંગ",
|
||||
e164: "E.164 નંબર",
|
||||
credit_card: "ક્રેડિટ કાર્ડ નંબર",
|
||||
currency_code: "ચલણ કોડ",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "ઇનપુટ",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
return `અમાન્ય ઇનપુટ: અપેક્ષિત ${expected}, પ્રાપ્ત ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `અમાન્ય ઇનપુટ: અપેક્ષિત ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `અમાન્ય વિકલ્પ: ${util.joinValues(issue.values, " | ")} માધ્યમથી એક અપેક્ષિત`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `ખૂબ મોટું: ${issue.origin ?? "મૂલ્ય"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "એલિમેન્ટ"} હોવા જોઈએ`;
|
||||
return `ખૂબ મોટું: ${issue.origin ?? "મૂલ્ય"} ${adj}${issue.maximum.toString()} હોવું જોઈએ`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `ખૂબ નાનું: ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} હોવા જોઈએ`;
|
||||
}
|
||||
return `ખૂબ નાનું: ${issue.origin} ${adj}${issue.minimum.toString()} હોવું જોઈએ`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `અમાન્ય સ્ટ્રિંગ: "${_issue.prefix}" થી શરૂ થવું જોઈએ`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `અમાન્ય સ્ટ્રિંગ: "${_issue.suffix}" પર સમાપ્ત થવું જોઈએ`;
|
||||
if (_issue.format === "includes")
|
||||
return `અમાન્ય સ્ટ્રિંગ: "${_issue.includes}" શામેલ હોવું જોઈએ`;
|
||||
if (_issue.format === "regex")
|
||||
return `અમાન્ય સ્ટ્રિંગ: પેટર્ન ${_issue.pattern} સાથે મેળ ખાવું જોઈએ`;
|
||||
return `અમાન્ય ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `અમાન્ય નંબર: ${issue.divisor} નો ગુણાંક હોવો જોઈએ`;
|
||||
case "unrecognized_keys":
|
||||
return `ઓળખી શકાતા નહીં તે કી${issue.keys.length > 1 ? "ઓ" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `${issue.origin} માં અમાન્ય કી`;
|
||||
case "invalid_union":
|
||||
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
|
||||
const opts = issue.options.map((o) => `'${o}'`).join(" | ");
|
||||
return `અમાન્ય ડિસ્ક્રિમિનેટર મૂલ્ય. અપેક્ષિત ${opts}`;
|
||||
}
|
||||
return "અમાન્ય ઇનપુટ";
|
||||
case "invalid_element":
|
||||
return `${issue.origin} માં અમાન્ય મૂલ્ય`;
|
||||
default:
|
||||
return "અમાન્ય ઇનપુટ";
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+248
@@ -0,0 +1,248 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
// Hebrew labels + grammatical gender
|
||||
const TypeNames = {
|
||||
string: { label: "מחרוזת", gender: "f" },
|
||||
number: { label: "מספר", gender: "m" },
|
||||
boolean: { label: "ערך בוליאני", gender: "m" },
|
||||
bigint: { label: "BigInt", gender: "m" },
|
||||
date: { label: "תאריך", gender: "m" },
|
||||
array: { label: "מערך", gender: "m" },
|
||||
object: { label: "אובייקט", gender: "m" },
|
||||
null: { label: "ערך ריק (null)", gender: "m" },
|
||||
undefined: { label: "ערך לא מוגדר (undefined)", gender: "m" },
|
||||
symbol: { label: "סימבול (Symbol)", gender: "m" },
|
||||
function: { label: "פונקציה", gender: "f" },
|
||||
map: { label: "מפה (Map)", gender: "f" },
|
||||
set: { label: "קבוצה (Set)", gender: "f" },
|
||||
file: { label: "קובץ", gender: "m" },
|
||||
promise: { label: "Promise", gender: "m" },
|
||||
NaN: { label: "NaN", gender: "m" },
|
||||
unknown: { label: "ערך לא ידוע", gender: "m" },
|
||||
value: { label: "ערך", gender: "m" },
|
||||
};
|
||||
// Sizing units for size-related messages + localized origin labels
|
||||
const Sizable = {
|
||||
string: { unit: "תווים", shortLabel: "קצר", longLabel: "ארוך" },
|
||||
file: { unit: "בייטים", shortLabel: "קטן", longLabel: "גדול" },
|
||||
array: { unit: "פריטים", shortLabel: "קטן", longLabel: "גדול" },
|
||||
set: { unit: "פריטים", shortLabel: "קטן", longLabel: "גדול" },
|
||||
number: { unit: "", shortLabel: "קטן", longLabel: "גדול" }, // no unit
|
||||
};
|
||||
// Helpers — labels, articles, and verbs
|
||||
const typeEntry = (t) => (t ? TypeNames[t] : undefined);
|
||||
const typeLabel = (t) => {
|
||||
const e = typeEntry(t);
|
||||
if (e)
|
||||
return e.label;
|
||||
// fallback: show raw string if unknown
|
||||
return t ?? TypeNames.unknown.label;
|
||||
};
|
||||
const withDefinite = (t) => `ה${typeLabel(t)}`;
|
||||
const verbFor = (t) => {
|
||||
const e = typeEntry(t);
|
||||
const gender = e?.gender ?? "m";
|
||||
return gender === "f" ? "צריכה להיות" : "צריך להיות";
|
||||
};
|
||||
const getSizing = (origin) => {
|
||||
if (!origin)
|
||||
return null;
|
||||
return Sizable[origin] ?? null;
|
||||
};
|
||||
const FormatDictionary = {
|
||||
regex: { label: "קלט", gender: "m" },
|
||||
email: { label: "כתובת אימייל", gender: "f" },
|
||||
url: { label: "כתובת רשת", gender: "f" },
|
||||
emoji: { label: "אימוג'י", gender: "m" },
|
||||
uuid: { label: "UUID", gender: "m" },
|
||||
uuidv4: { label: "UUIDv4", gender: "m" },
|
||||
uuidv6: { label: "UUIDv6", gender: "m" },
|
||||
nanoid: { label: "nanoid", gender: "m" },
|
||||
guid: { label: "GUID", gender: "m" },
|
||||
cuid: { label: "cuid", gender: "m" },
|
||||
cuid2: { label: "cuid2", gender: "m" },
|
||||
ulid: { label: "ULID", gender: "m" },
|
||||
xid: { label: "XID", gender: "m" },
|
||||
ksuid: { label: "KSUID", gender: "m" },
|
||||
datetime: { label: "תאריך וזמן ISO", gender: "m" },
|
||||
date: { label: "תאריך ISO", gender: "m" },
|
||||
time: { label: "זמן ISO", gender: "m" },
|
||||
duration: { label: "משך זמן ISO", gender: "m" },
|
||||
ipv4: { label: "כתובת IPv4", gender: "f" },
|
||||
ipv6: { label: "כתובת IPv6", gender: "f" },
|
||||
mac: { label: "כתובת MAC", gender: "f" },
|
||||
cidrv4: { label: "טווח IPv4", gender: "m" },
|
||||
cidrv6: { label: "טווח IPv6", gender: "m" },
|
||||
base64: { label: "מחרוזת בבסיס 64", gender: "f" },
|
||||
base64url: { label: "מחרוזת בבסיס 64 לכתובות רשת", gender: "f" },
|
||||
json_string: { label: "מחרוזת JSON", gender: "f" },
|
||||
e164: { label: "מספר E.164", gender: "m" },
|
||||
credit_card: { label: "מספר כרטיס אשראי", gender: "m" },
|
||||
currency_code: { label: "קוד מטבע", gender: "m" },
|
||||
iban: { label: "IBAN", gender: "m" },
|
||||
jwt: { label: "JWT", gender: "m" },
|
||||
template_literal: { label: "קלט", gender: "m" },
|
||||
ends_with: { label: "קלט", gender: "m" },
|
||||
includes: { label: "קלט", gender: "m" },
|
||||
lowercase: { label: "קלט", gender: "m" },
|
||||
starts_with: { label: "קלט", gender: "m" },
|
||||
uppercase: { label: "קלט", gender: "m" },
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
// Expected type: show without definite article for clearer Hebrew
|
||||
const expectedKey = issue.expected;
|
||||
const expected = TypeDictionary[expectedKey ?? ""] ?? typeLabel(expectedKey);
|
||||
// Received: show localized label if known, otherwise constructor/raw
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? TypeNames[receivedType]?.label ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `קלט לא תקין: צריך להיות instanceof ${issue.expected}, התקבל ${received}`;
|
||||
}
|
||||
return `קלט לא תקין: צריך להיות ${expected}, התקבל ${received}`;
|
||||
}
|
||||
case "invalid_value": {
|
||||
if (issue.values.length === 1) {
|
||||
return `ערך לא תקין: הערך חייב להיות ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
}
|
||||
// Join values with proper Hebrew formatting
|
||||
const stringified = issue.values.map((v) => util.stringifyPrimitive(v));
|
||||
if (issue.values.length === 2) {
|
||||
return `ערך לא תקין: האפשרויות המתאימות הן ${stringified[0]} או ${stringified[1]}`;
|
||||
}
|
||||
// For 3+ values: "a", "b" או "c"
|
||||
const lastValue = stringified[stringified.length - 1];
|
||||
const restValues = stringified.slice(0, -1).join(", ");
|
||||
return `ערך לא תקין: האפשרויות המתאימות הן ${restValues} או ${lastValue}`;
|
||||
}
|
||||
case "too_big": {
|
||||
const sizing = getSizing(issue.origin);
|
||||
const subject = withDefinite(issue.origin ?? "value");
|
||||
if (issue.origin === "string") {
|
||||
// Special handling for strings - more natural Hebrew
|
||||
return `${sizing?.longLabel ?? "ארוך"} מדי: ${subject} צריכה להכיל ${issue.maximum.toString()} ${sizing?.unit ?? ""} ${issue.inclusive ? "או פחות" : "לכל היותר"}`.trim();
|
||||
}
|
||||
if (issue.origin === "number") {
|
||||
// Natural Hebrew for numbers
|
||||
const comparison = issue.inclusive ? `קטן או שווה ל-${issue.maximum}` : `קטן מ-${issue.maximum}`;
|
||||
return `גדול מדי: ${subject} צריך להיות ${comparison}`;
|
||||
}
|
||||
if (issue.origin === "array" || issue.origin === "set") {
|
||||
// Natural Hebrew for arrays and sets
|
||||
const verb = issue.origin === "set" ? "צריכה" : "צריך";
|
||||
const comparison = issue.inclusive
|
||||
? `${issue.maximum} ${sizing?.unit ?? ""} או פחות`
|
||||
: `פחות מ-${issue.maximum} ${sizing?.unit ?? ""}`;
|
||||
return `גדול מדי: ${subject} ${verb} להכיל ${comparison}`.trim();
|
||||
}
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const be = verbFor(issue.origin ?? "value");
|
||||
if (sizing?.unit) {
|
||||
return `${sizing.longLabel} מדי: ${subject} ${be} ${adj}${issue.maximum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `${sizing?.longLabel ?? "גדול"} מדי: ${subject} ${be} ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const sizing = getSizing(issue.origin);
|
||||
const subject = withDefinite(issue.origin ?? "value");
|
||||
if (issue.origin === "string") {
|
||||
// Special handling for strings - more natural Hebrew
|
||||
return `${sizing?.shortLabel ?? "קצר"} מדי: ${subject} צריכה להכיל ${issue.minimum.toString()} ${sizing?.unit ?? ""} ${issue.inclusive ? "או יותר" : "לפחות"}`.trim();
|
||||
}
|
||||
if (issue.origin === "number") {
|
||||
// Natural Hebrew for numbers
|
||||
const comparison = issue.inclusive ? `גדול או שווה ל-${issue.minimum}` : `גדול מ-${issue.minimum}`;
|
||||
return `קטן מדי: ${subject} צריך להיות ${comparison}`;
|
||||
}
|
||||
if (issue.origin === "array" || issue.origin === "set") {
|
||||
// Natural Hebrew for arrays and sets
|
||||
const verb = issue.origin === "set" ? "צריכה" : "צריך";
|
||||
// Special case for singular (minimum === 1)
|
||||
if (issue.minimum === 1 && issue.inclusive) {
|
||||
const singularPhrase = issue.origin === "set" ? "לפחות פריט אחד" : "לפחות פריט אחד";
|
||||
return `קטן מדי: ${subject} ${verb} להכיל ${singularPhrase}`;
|
||||
}
|
||||
const comparison = issue.inclusive
|
||||
? `${issue.minimum} ${sizing?.unit ?? ""} או יותר`
|
||||
: `יותר מ-${issue.minimum} ${sizing?.unit ?? ""}`;
|
||||
return `קטן מדי: ${subject} ${verb} להכיל ${comparison}`.trim();
|
||||
}
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const be = verbFor(issue.origin ?? "value");
|
||||
if (sizing?.unit) {
|
||||
return `${sizing.shortLabel} מדי: ${subject} ${be} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `${sizing?.shortLabel ?? "קטן"} מדי: ${subject} ${be} ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
// These apply to strings — use feminine grammar + ה׳ הידיעה
|
||||
if (_issue.format === "starts_with")
|
||||
return `המחרוזת חייבת להתחיל ב "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `המחרוזת חייבת להסתיים ב "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `המחרוזת חייבת לכלול "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `המחרוזת חייבת להתאים לתבנית ${_issue.pattern}`;
|
||||
// Handle gender agreement for formats
|
||||
const nounEntry = FormatDictionary[_issue.format];
|
||||
const noun = nounEntry?.label ?? _issue.format;
|
||||
const gender = nounEntry?.gender ?? "m";
|
||||
const adjective = gender === "f" ? "תקינה" : "תקין";
|
||||
return `${noun} לא ${adjective}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `מספר לא תקין: חייב להיות מכפלה של ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `מפתח${issue.keys.length > 1 ? "ות" : ""} לא מזוה${issue.keys.length > 1 ? "ים" : "ה"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key": {
|
||||
return `שדה לא תקין באובייקט`;
|
||||
}
|
||||
case "invalid_union":
|
||||
return "קלט לא תקין";
|
||||
case "invalid_element": {
|
||||
const place = withDefinite(issue.origin ?? "array");
|
||||
return `ערך לא תקין ב${place}`;
|
||||
}
|
||||
default:
|
||||
return `קלט לא תקין`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+221
@@ -0,0 +1,221 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
// Hebrew labels + grammatical gender
|
||||
const TypeNames = {
|
||||
string: { label: "מחרוזת", gender: "f" },
|
||||
number: { label: "מספר", gender: "m" },
|
||||
boolean: { label: "ערך בוליאני", gender: "m" },
|
||||
bigint: { label: "BigInt", gender: "m" },
|
||||
date: { label: "תאריך", gender: "m" },
|
||||
array: { label: "מערך", gender: "m" },
|
||||
object: { label: "אובייקט", gender: "m" },
|
||||
null: { label: "ערך ריק (null)", gender: "m" },
|
||||
undefined: { label: "ערך לא מוגדר (undefined)", gender: "m" },
|
||||
symbol: { label: "סימבול (Symbol)", gender: "m" },
|
||||
function: { label: "פונקציה", gender: "f" },
|
||||
map: { label: "מפה (Map)", gender: "f" },
|
||||
set: { label: "קבוצה (Set)", gender: "f" },
|
||||
file: { label: "קובץ", gender: "m" },
|
||||
promise: { label: "Promise", gender: "m" },
|
||||
NaN: { label: "NaN", gender: "m" },
|
||||
unknown: { label: "ערך לא ידוע", gender: "m" },
|
||||
value: { label: "ערך", gender: "m" },
|
||||
};
|
||||
// Sizing units for size-related messages + localized origin labels
|
||||
const Sizable = {
|
||||
string: { unit: "תווים", shortLabel: "קצר", longLabel: "ארוך" },
|
||||
file: { unit: "בייטים", shortLabel: "קטן", longLabel: "גדול" },
|
||||
array: { unit: "פריטים", shortLabel: "קטן", longLabel: "גדול" },
|
||||
set: { unit: "פריטים", shortLabel: "קטן", longLabel: "גדול" },
|
||||
number: { unit: "", shortLabel: "קטן", longLabel: "גדול" }, // no unit
|
||||
};
|
||||
// Helpers — labels, articles, and verbs
|
||||
const typeEntry = (t) => (t ? TypeNames[t] : undefined);
|
||||
const typeLabel = (t) => {
|
||||
const e = typeEntry(t);
|
||||
if (e)
|
||||
return e.label;
|
||||
// fallback: show raw string if unknown
|
||||
return t ?? TypeNames.unknown.label;
|
||||
};
|
||||
const withDefinite = (t) => `ה${typeLabel(t)}`;
|
||||
const verbFor = (t) => {
|
||||
const e = typeEntry(t);
|
||||
const gender = e?.gender ?? "m";
|
||||
return gender === "f" ? "צריכה להיות" : "צריך להיות";
|
||||
};
|
||||
const getSizing = (origin) => {
|
||||
if (!origin)
|
||||
return null;
|
||||
return Sizable[origin] ?? null;
|
||||
};
|
||||
const FormatDictionary = {
|
||||
regex: { label: "קלט", gender: "m" },
|
||||
email: { label: "כתובת אימייל", gender: "f" },
|
||||
url: { label: "כתובת רשת", gender: "f" },
|
||||
emoji: { label: "אימוג'י", gender: "m" },
|
||||
uuid: { label: "UUID", gender: "m" },
|
||||
uuidv4: { label: "UUIDv4", gender: "m" },
|
||||
uuidv6: { label: "UUIDv6", gender: "m" },
|
||||
nanoid: { label: "nanoid", gender: "m" },
|
||||
guid: { label: "GUID", gender: "m" },
|
||||
cuid: { label: "cuid", gender: "m" },
|
||||
cuid2: { label: "cuid2", gender: "m" },
|
||||
ulid: { label: "ULID", gender: "m" },
|
||||
xid: { label: "XID", gender: "m" },
|
||||
ksuid: { label: "KSUID", gender: "m" },
|
||||
datetime: { label: "תאריך וזמן ISO", gender: "m" },
|
||||
date: { label: "תאריך ISO", gender: "m" },
|
||||
time: { label: "זמן ISO", gender: "m" },
|
||||
duration: { label: "משך זמן ISO", gender: "m" },
|
||||
ipv4: { label: "כתובת IPv4", gender: "f" },
|
||||
ipv6: { label: "כתובת IPv6", gender: "f" },
|
||||
mac: { label: "כתובת MAC", gender: "f" },
|
||||
cidrv4: { label: "טווח IPv4", gender: "m" },
|
||||
cidrv6: { label: "טווח IPv6", gender: "m" },
|
||||
base64: { label: "מחרוזת בבסיס 64", gender: "f" },
|
||||
base64url: { label: "מחרוזת בבסיס 64 לכתובות רשת", gender: "f" },
|
||||
json_string: { label: "מחרוזת JSON", gender: "f" },
|
||||
e164: { label: "מספר E.164", gender: "m" },
|
||||
credit_card: { label: "מספר כרטיס אשראי", gender: "m" },
|
||||
currency_code: { label: "קוד מטבע", gender: "m" },
|
||||
iban: { label: "IBAN", gender: "m" },
|
||||
jwt: { label: "JWT", gender: "m" },
|
||||
template_literal: { label: "קלט", gender: "m" },
|
||||
ends_with: { label: "קלט", gender: "m" },
|
||||
includes: { label: "קלט", gender: "m" },
|
||||
lowercase: { label: "קלט", gender: "m" },
|
||||
starts_with: { label: "קלט", gender: "m" },
|
||||
uppercase: { label: "קלט", gender: "m" },
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
// Expected type: show without definite article for clearer Hebrew
|
||||
const expectedKey = issue.expected;
|
||||
const expected = TypeDictionary[expectedKey ?? ""] ?? typeLabel(expectedKey);
|
||||
// Received: show localized label if known, otherwise constructor/raw
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? TypeNames[receivedType]?.label ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `קלט לא תקין: צריך להיות instanceof ${issue.expected}, התקבל ${received}`;
|
||||
}
|
||||
return `קלט לא תקין: צריך להיות ${expected}, התקבל ${received}`;
|
||||
}
|
||||
case "invalid_value": {
|
||||
if (issue.values.length === 1) {
|
||||
return `ערך לא תקין: הערך חייב להיות ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
}
|
||||
// Join values with proper Hebrew formatting
|
||||
const stringified = issue.values.map((v) => util.stringifyPrimitive(v));
|
||||
if (issue.values.length === 2) {
|
||||
return `ערך לא תקין: האפשרויות המתאימות הן ${stringified[0]} או ${stringified[1]}`;
|
||||
}
|
||||
// For 3+ values: "a", "b" או "c"
|
||||
const lastValue = stringified[stringified.length - 1];
|
||||
const restValues = stringified.slice(0, -1).join(", ");
|
||||
return `ערך לא תקין: האפשרויות המתאימות הן ${restValues} או ${lastValue}`;
|
||||
}
|
||||
case "too_big": {
|
||||
const sizing = getSizing(issue.origin);
|
||||
const subject = withDefinite(issue.origin ?? "value");
|
||||
if (issue.origin === "string") {
|
||||
// Special handling for strings - more natural Hebrew
|
||||
return `${sizing?.longLabel ?? "ארוך"} מדי: ${subject} צריכה להכיל ${issue.maximum.toString()} ${sizing?.unit ?? ""} ${issue.inclusive ? "או פחות" : "לכל היותר"}`.trim();
|
||||
}
|
||||
if (issue.origin === "number") {
|
||||
// Natural Hebrew for numbers
|
||||
const comparison = issue.inclusive ? `קטן או שווה ל-${issue.maximum}` : `קטן מ-${issue.maximum}`;
|
||||
return `גדול מדי: ${subject} צריך להיות ${comparison}`;
|
||||
}
|
||||
if (issue.origin === "array" || issue.origin === "set") {
|
||||
// Natural Hebrew for arrays and sets
|
||||
const verb = issue.origin === "set" ? "צריכה" : "צריך";
|
||||
const comparison = issue.inclusive
|
||||
? `${issue.maximum} ${sizing?.unit ?? ""} או פחות`
|
||||
: `פחות מ-${issue.maximum} ${sizing?.unit ?? ""}`;
|
||||
return `גדול מדי: ${subject} ${verb} להכיל ${comparison}`.trim();
|
||||
}
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const be = verbFor(issue.origin ?? "value");
|
||||
if (sizing?.unit) {
|
||||
return `${sizing.longLabel} מדי: ${subject} ${be} ${adj}${issue.maximum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `${sizing?.longLabel ?? "גדול"} מדי: ${subject} ${be} ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const sizing = getSizing(issue.origin);
|
||||
const subject = withDefinite(issue.origin ?? "value");
|
||||
if (issue.origin === "string") {
|
||||
// Special handling for strings - more natural Hebrew
|
||||
return `${sizing?.shortLabel ?? "קצר"} מדי: ${subject} צריכה להכיל ${issue.minimum.toString()} ${sizing?.unit ?? ""} ${issue.inclusive ? "או יותר" : "לפחות"}`.trim();
|
||||
}
|
||||
if (issue.origin === "number") {
|
||||
// Natural Hebrew for numbers
|
||||
const comparison = issue.inclusive ? `גדול או שווה ל-${issue.minimum}` : `גדול מ-${issue.minimum}`;
|
||||
return `קטן מדי: ${subject} צריך להיות ${comparison}`;
|
||||
}
|
||||
if (issue.origin === "array" || issue.origin === "set") {
|
||||
// Natural Hebrew for arrays and sets
|
||||
const verb = issue.origin === "set" ? "צריכה" : "צריך";
|
||||
// Special case for singular (minimum === 1)
|
||||
if (issue.minimum === 1 && issue.inclusive) {
|
||||
const singularPhrase = issue.origin === "set" ? "לפחות פריט אחד" : "לפחות פריט אחד";
|
||||
return `קטן מדי: ${subject} ${verb} להכיל ${singularPhrase}`;
|
||||
}
|
||||
const comparison = issue.inclusive
|
||||
? `${issue.minimum} ${sizing?.unit ?? ""} או יותר`
|
||||
: `יותר מ-${issue.minimum} ${sizing?.unit ?? ""}`;
|
||||
return `קטן מדי: ${subject} ${verb} להכיל ${comparison}`.trim();
|
||||
}
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const be = verbFor(issue.origin ?? "value");
|
||||
if (sizing?.unit) {
|
||||
return `${sizing.shortLabel} מדי: ${subject} ${be} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `${sizing?.shortLabel ?? "קטן"} מדי: ${subject} ${be} ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
// These apply to strings — use feminine grammar + ה׳ הידיעה
|
||||
if (_issue.format === "starts_with")
|
||||
return `המחרוזת חייבת להתחיל ב "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `המחרוזת חייבת להסתיים ב "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `המחרוזת חייבת לכלול "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `המחרוזת חייבת להתאים לתבנית ${_issue.pattern}`;
|
||||
// Handle gender agreement for formats
|
||||
const nounEntry = FormatDictionary[_issue.format];
|
||||
const noun = nounEntry?.label ?? _issue.format;
|
||||
const gender = nounEntry?.gender ?? "m";
|
||||
const adjective = gender === "f" ? "תקינה" : "תקין";
|
||||
return `${noun} לא ${adjective}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `מספר לא תקין: חייב להיות מכפלה של ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `מפתח${issue.keys.length > 1 ? "ות" : ""} לא מזוה${issue.keys.length > 1 ? "ים" : "ה"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key": {
|
||||
return `שדה לא תקין באובייקט`;
|
||||
}
|
||||
case "invalid_union":
|
||||
return "קלט לא תקין";
|
||||
case "invalid_element": {
|
||||
const place = withDefinite(issue.origin ?? "array");
|
||||
return `ערך לא תקין ב${place}`;
|
||||
}
|
||||
default:
|
||||
return `קלט לא תקין`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "अक्षर", verb: "रखने के लिए" },
|
||||
file: { unit: "बाइट्स", verb: "रखने के लिए" },
|
||||
array: { unit: "तत्व", verb: "रखने के लिए" },
|
||||
set: { unit: "तत्व", verb: "रखने के लिए" },
|
||||
map: { unit: "प्रविष्टियाँ", verb: "रखने के लिए" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "इनपुट",
|
||||
email: "ईमेल पता",
|
||||
url: "URL",
|
||||
emoji: "इमोजी",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO तिथि और समय",
|
||||
date: "ISO तिथि",
|
||||
time: "ISO समय",
|
||||
duration: "ISO अवधि",
|
||||
ipv4: "IPv4 पता",
|
||||
ipv6: "IPv6 पता",
|
||||
mac: "MAC पता",
|
||||
cidrv4: "IPv4 श्रेणी",
|
||||
cidrv6: "IPv6 श्रेणी",
|
||||
base64: "Base64-एन्कोडेड स्ट्रिंग",
|
||||
base64url: "Base64URL-एन्कोडेड स्ट्रिंग",
|
||||
json_string: "JSON स्ट्रिंग",
|
||||
e164: "E.164 संख्या",
|
||||
credit_card: "क्रेडिट कार्ड संख्या",
|
||||
currency_code: "मुद्रा कोड",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "इनपुट",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
return `अमान्य इनपुट: अपेक्षित ${expected}, प्राप्त ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `अमान्य इनपुट: अपेक्षित ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `अमान्य विकल्प: अपेक्षित मानों में से एक ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `बहुत बड़ा: अपेक्षित था कि ${issue.origin ?? "मान"} में ${adj}${issue.maximum} ${sizing.unit} हों`;
|
||||
return `बहुत बड़ा: अपेक्षित था कि ${issue.origin ?? "मान"} ${adj}${issue.maximum} हो`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `बहुत छोटा: अपेक्षित था कि ${issue.origin} में ${adj}${issue.minimum} ${sizing.unit} हों`;
|
||||
return `बहुत छोटा: अपेक्षित था कि ${issue.origin} ${adj}${issue.minimum} हो`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `अमान्य स्ट्रिंग: "${_issue.prefix}" से शुरू होना चाहिए`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `अमान्य स्ट्रिंग: "${_issue.suffix}" पर समाप्त होना चाहिए`;
|
||||
if (_issue.format === "includes")
|
||||
return `अमान्य स्ट्रिंग: इसमें "${_issue.includes}" शामिल होना चाहिए`;
|
||||
if (_issue.format === "regex")
|
||||
return `अमान्य स्ट्रिंग: पैटर्न ${_issue.pattern} से मेल खाना चाहिए`;
|
||||
return `अमान्य ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `अमान्य संख्या: यह ${issue.divisor} का गुणज होना चाहिए`;
|
||||
case "unrecognized_keys":
|
||||
return `अपरिचित कुंजी${issue.keys.length > 1 ? "याँ" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `अमान्य कुंजी: ${issue.origin} में`;
|
||||
case "invalid_union":
|
||||
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
|
||||
const opts = issue.options.map((o) => `'${o}'`).join(" | ");
|
||||
return `अमान्य डिस्क्रिमिनेटर मान: अपेक्षित ${opts}`;
|
||||
}
|
||||
return "अमान्य इनपुट";
|
||||
case "invalid_element":
|
||||
return `अमान्य मान: ${issue.origin} में`;
|
||||
default:
|
||||
return `अमान्य इनपुट`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "अक्षर", verb: "रखने के लिए" },
|
||||
file: { unit: "बाइट्स", verb: "रखने के लिए" },
|
||||
array: { unit: "तत्व", verb: "रखने के लिए" },
|
||||
set: { unit: "तत्व", verb: "रखने के लिए" },
|
||||
map: { unit: "प्रविष्टियाँ", verb: "रखने के लिए" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "इनपुट",
|
||||
email: "ईमेल पता",
|
||||
url: "URL",
|
||||
emoji: "इमोजी",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO तिथि और समय",
|
||||
date: "ISO तिथि",
|
||||
time: "ISO समय",
|
||||
duration: "ISO अवधि",
|
||||
ipv4: "IPv4 पता",
|
||||
ipv6: "IPv6 पता",
|
||||
mac: "MAC पता",
|
||||
cidrv4: "IPv4 श्रेणी",
|
||||
cidrv6: "IPv6 श्रेणी",
|
||||
base64: "Base64-एन्कोडेड स्ट्रिंग",
|
||||
base64url: "Base64URL-एन्कोडेड स्ट्रिंग",
|
||||
json_string: "JSON स्ट्रिंग",
|
||||
e164: "E.164 संख्या",
|
||||
credit_card: "क्रेडिट कार्ड संख्या",
|
||||
currency_code: "मुद्रा कोड",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "इनपुट",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
return `अमान्य इनपुट: अपेक्षित ${expected}, प्राप्त ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `अमान्य इनपुट: अपेक्षित ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `अमान्य विकल्प: अपेक्षित मानों में से एक ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `बहुत बड़ा: अपेक्षित था कि ${issue.origin ?? "मान"} में ${adj}${issue.maximum} ${sizing.unit} हों`;
|
||||
return `बहुत बड़ा: अपेक्षित था कि ${issue.origin ?? "मान"} ${adj}${issue.maximum} हो`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `बहुत छोटा: अपेक्षित था कि ${issue.origin} में ${adj}${issue.minimum} ${sizing.unit} हों`;
|
||||
return `बहुत छोटा: अपेक्षित था कि ${issue.origin} ${adj}${issue.minimum} हो`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `अमान्य स्ट्रिंग: "${_issue.prefix}" से शुरू होना चाहिए`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `अमान्य स्ट्रिंग: "${_issue.suffix}" पर समाप्त होना चाहिए`;
|
||||
if (_issue.format === "includes")
|
||||
return `अमान्य स्ट्रिंग: इसमें "${_issue.includes}" शामिल होना चाहिए`;
|
||||
if (_issue.format === "regex")
|
||||
return `अमान्य स्ट्रिंग: पैटर्न ${_issue.pattern} से मेल खाना चाहिए`;
|
||||
return `अमान्य ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `अमान्य संख्या: यह ${issue.divisor} का गुणज होना चाहिए`;
|
||||
case "unrecognized_keys":
|
||||
return `अपरिचित कुंजी${issue.keys.length > 1 ? "याँ" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `अमान्य कुंजी: ${issue.origin} में`;
|
||||
case "invalid_union":
|
||||
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
|
||||
const opts = issue.options.map((o) => `'${o}'`).join(" | ");
|
||||
return `अमान्य डिस्क्रिमिनेटर मान: अपेक्षित ${opts}`;
|
||||
}
|
||||
return "अमान्य इनपुट";
|
||||
case "invalid_element":
|
||||
return `अमान्य मान: ${issue.origin} में`;
|
||||
default:
|
||||
return `अमान्य इनपुट`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "znakova", verb: "imati" },
|
||||
file: { unit: "bajtova", verb: "imati" },
|
||||
array: { unit: "stavki", verb: "imati" },
|
||||
set: { unit: "stavki", verb: "imati" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "unos",
|
||||
email: "email adresa",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO datum i vrijeme",
|
||||
date: "ISO datum",
|
||||
time: "ISO vrijeme",
|
||||
duration: "ISO trajanje",
|
||||
ipv4: "IPv4 adresa",
|
||||
ipv6: "IPv6 adresa",
|
||||
mac: "MAC adresa",
|
||||
cidrv4: "IPv4 raspon",
|
||||
cidrv6: "IPv6 raspon",
|
||||
base64: "base64 kodirani tekst",
|
||||
base64url: "base64url kodirani tekst",
|
||||
json_string: "JSON tekst",
|
||||
e164: "E.164 broj",
|
||||
credit_card: "broj kreditne kartice",
|
||||
currency_code: "kod valute",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "unos",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
string: "tekst",
|
||||
number: "broj",
|
||||
boolean: "boolean",
|
||||
array: "niz",
|
||||
object: "objekt",
|
||||
set: "skup",
|
||||
file: "datoteka",
|
||||
date: "datum",
|
||||
bigint: "bigint",
|
||||
symbol: "simbol",
|
||||
undefined: "undefined",
|
||||
null: "null",
|
||||
function: "funkcija",
|
||||
map: "mapa",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Neispravan unos: očekuje se instanceof ${issue.expected}, a primljeno je ${received}`;
|
||||
}
|
||||
return `Neispravan unos: očekuje se ${expected}, a primljeno je ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Neispravna vrijednost: očekivano ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Neispravna opcija: očekivano jedno od ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
const origin = TypeDictionary[issue.origin] ?? issue.origin;
|
||||
if (sizing)
|
||||
return `Preveliko: očekivano da ${origin ?? "vrijednost"} ima ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemenata"}`;
|
||||
return `Preveliko: očekivano da ${origin ?? "vrijednost"} bude ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
const origin = TypeDictionary[issue.origin] ?? issue.origin;
|
||||
if (sizing) {
|
||||
return `Premalo: očekivano da ${origin} ima ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Premalo: očekivano da ${origin} bude ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Neispravan tekst: mora započinjati s "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Neispravan tekst: mora završavati s "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Neispravan tekst: mora sadržavati "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Neispravan tekst: mora odgovarati uzorku ${_issue.pattern}`;
|
||||
return `Neispravna ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Neispravan broj: mora biti višekratnik od ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Neprepoznat${issue.keys.length > 1 ? "i ključevi" : " ključ"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Neispravan ključ u ${TypeDictionary[issue.origin] ?? issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Neispravan unos";
|
||||
case "invalid_element":
|
||||
return `Neispravna vrijednost u ${TypeDictionary[issue.origin] ?? issue.origin}`;
|
||||
default:
|
||||
return `Neispravan unos`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "znakova", verb: "imati" },
|
||||
file: { unit: "bajtova", verb: "imati" },
|
||||
array: { unit: "stavki", verb: "imati" },
|
||||
set: { unit: "stavki", verb: "imati" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "unos",
|
||||
email: "email adresa",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO datum i vrijeme",
|
||||
date: "ISO datum",
|
||||
time: "ISO vrijeme",
|
||||
duration: "ISO trajanje",
|
||||
ipv4: "IPv4 adresa",
|
||||
ipv6: "IPv6 adresa",
|
||||
mac: "MAC adresa",
|
||||
cidrv4: "IPv4 raspon",
|
||||
cidrv6: "IPv6 raspon",
|
||||
base64: "base64 kodirani tekst",
|
||||
base64url: "base64url kodirani tekst",
|
||||
json_string: "JSON tekst",
|
||||
e164: "E.164 broj",
|
||||
credit_card: "broj kreditne kartice",
|
||||
currency_code: "kod valute",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "unos",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
string: "tekst",
|
||||
number: "broj",
|
||||
boolean: "boolean",
|
||||
array: "niz",
|
||||
object: "objekt",
|
||||
set: "skup",
|
||||
file: "datoteka",
|
||||
date: "datum",
|
||||
bigint: "bigint",
|
||||
symbol: "simbol",
|
||||
undefined: "undefined",
|
||||
null: "null",
|
||||
function: "funkcija",
|
||||
map: "mapa",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Neispravan unos: očekuje se instanceof ${issue.expected}, a primljeno je ${received}`;
|
||||
}
|
||||
return `Neispravan unos: očekuje se ${expected}, a primljeno je ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Neispravna vrijednost: očekivano ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Neispravna opcija: očekivano jedno od ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
const origin = TypeDictionary[issue.origin] ?? issue.origin;
|
||||
if (sizing)
|
||||
return `Preveliko: očekivano da ${origin ?? "vrijednost"} ima ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemenata"}`;
|
||||
return `Preveliko: očekivano da ${origin ?? "vrijednost"} bude ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
const origin = TypeDictionary[issue.origin] ?? issue.origin;
|
||||
if (sizing) {
|
||||
return `Premalo: očekivano da ${origin} ima ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Premalo: očekivano da ${origin} bude ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Neispravan tekst: mora započinjati s "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Neispravan tekst: mora završavati s "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Neispravan tekst: mora sadržavati "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Neispravan tekst: mora odgovarati uzorku ${_issue.pattern}`;
|
||||
return `Neispravna ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Neispravan broj: mora biti višekratnik od ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Neprepoznat${issue.keys.length > 1 ? "i ključevi" : " ključ"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Neispravan ključ u ${TypeDictionary[issue.origin] ?? issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Neispravan unos";
|
||||
case "invalid_element":
|
||||
return `Neispravna vrijednost u ${TypeDictionary[issue.origin] ?? issue.origin}`;
|
||||
default:
|
||||
return `Neispravan unos`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "karakter", verb: "legyen" },
|
||||
file: { unit: "byte", verb: "legyen" },
|
||||
array: { unit: "elem", verb: "legyen" },
|
||||
set: { unit: "elem", verb: "legyen" },
|
||||
map: { unit: "elem", verb: "legyen" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "bemenet",
|
||||
email: "email cím",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO időbélyeg",
|
||||
date: "ISO dátum",
|
||||
time: "ISO idő",
|
||||
duration: "ISO időintervallum",
|
||||
ipv4: "IPv4 cím",
|
||||
ipv6: "IPv6 cím",
|
||||
mac: "MAC cím",
|
||||
cidrv4: "IPv4 tartomány",
|
||||
cidrv6: "IPv6 tartomány",
|
||||
base64: "base64-kódolt string",
|
||||
base64url: "base64url-kódolt string",
|
||||
json_string: "JSON string",
|
||||
e164: "E.164 szám",
|
||||
credit_card: "hitelkártyaszám",
|
||||
currency_code: "pénznemkód",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "bemenet",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "szám",
|
||||
array: "tömb",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Érvénytelen bemenet: a várt érték instanceof ${issue.expected}, a kapott érték ${received}`;
|
||||
}
|
||||
return `Érvénytelen bemenet: a várt érték ${expected}, a kapott érték ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Érvénytelen bemenet: a várt érték ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Érvénytelen opció: valamelyik érték várt ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Túl nagy: ${issue.origin ?? "érték"} mérete túl nagy ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elem"}`;
|
||||
return `Túl nagy: a bemeneti érték ${issue.origin ?? "érték"} túl nagy: ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Túl kicsi: a bemeneti érték ${issue.origin} mérete túl kicsi ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Túl kicsi: a bemeneti érték ${issue.origin} túl kicsi ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Érvénytelen string: "${_issue.prefix}" értékkel kell kezdődnie`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Érvénytelen string: "${_issue.suffix}" értékkel kell végződnie`;
|
||||
if (_issue.format === "includes")
|
||||
return `Érvénytelen string: "${_issue.includes}" értéket kell tartalmaznia`;
|
||||
if (_issue.format === "regex")
|
||||
return `Érvénytelen string: ${_issue.pattern} mintának kell megfelelnie`;
|
||||
return `Érvénytelen ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Érvénytelen szám: ${issue.divisor} többszörösének kell lennie`;
|
||||
case "unrecognized_keys":
|
||||
return `Ismeretlen kulcs${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Érvénytelen kulcs ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Érvénytelen bemenet";
|
||||
case "invalid_element":
|
||||
return `Érvénytelen érték: ${issue.origin}`;
|
||||
default:
|
||||
return `Érvénytelen bemenet`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "karakter", verb: "legyen" },
|
||||
file: { unit: "byte", verb: "legyen" },
|
||||
array: { unit: "elem", verb: "legyen" },
|
||||
set: { unit: "elem", verb: "legyen" },
|
||||
map: { unit: "elem", verb: "legyen" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "bemenet",
|
||||
email: "email cím",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO időbélyeg",
|
||||
date: "ISO dátum",
|
||||
time: "ISO idő",
|
||||
duration: "ISO időintervallum",
|
||||
ipv4: "IPv4 cím",
|
||||
ipv6: "IPv6 cím",
|
||||
mac: "MAC cím",
|
||||
cidrv4: "IPv4 tartomány",
|
||||
cidrv6: "IPv6 tartomány",
|
||||
base64: "base64-kódolt string",
|
||||
base64url: "base64url-kódolt string",
|
||||
json_string: "JSON string",
|
||||
e164: "E.164 szám",
|
||||
credit_card: "hitelkártyaszám",
|
||||
currency_code: "pénznemkód",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "bemenet",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "szám",
|
||||
array: "tömb",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Érvénytelen bemenet: a várt érték instanceof ${issue.expected}, a kapott érték ${received}`;
|
||||
}
|
||||
return `Érvénytelen bemenet: a várt érték ${expected}, a kapott érték ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Érvénytelen bemenet: a várt érték ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Érvénytelen opció: valamelyik érték várt ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Túl nagy: ${issue.origin ?? "érték"} mérete túl nagy ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elem"}`;
|
||||
return `Túl nagy: a bemeneti érték ${issue.origin ?? "érték"} túl nagy: ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Túl kicsi: a bemeneti érték ${issue.origin} mérete túl kicsi ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Túl kicsi: a bemeneti érték ${issue.origin} túl kicsi ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Érvénytelen string: "${_issue.prefix}" értékkel kell kezdődnie`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Érvénytelen string: "${_issue.suffix}" értékkel kell végződnie`;
|
||||
if (_issue.format === "includes")
|
||||
return `Érvénytelen string: "${_issue.includes}" értéket kell tartalmaznia`;
|
||||
if (_issue.format === "regex")
|
||||
return `Érvénytelen string: ${_issue.pattern} mintának kell megfelelnie`;
|
||||
return `Érvénytelen ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Érvénytelen szám: ${issue.divisor} többszörösének kell lennie`;
|
||||
case "unrecognized_keys":
|
||||
return `Ismeretlen kulcs${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Érvénytelen kulcs ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Érvénytelen bemenet";
|
||||
case "invalid_element":
|
||||
return `Érvénytelen érték: ${issue.origin}`;
|
||||
default:
|
||||
return `Érvénytelen bemenet`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
function getArmenianPlural(count, one, many) {
|
||||
return Math.abs(count) === 1 ? one : many;
|
||||
}
|
||||
function withDefiniteArticle(word) {
|
||||
if (!word)
|
||||
return "";
|
||||
const vowels = ["ա", "ե", "ը", "ի", "ո", "ու", "օ"];
|
||||
const lastChar = word[word.length - 1];
|
||||
return word + (vowels.includes(lastChar) ? "ն" : "ը");
|
||||
}
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: {
|
||||
unit: {
|
||||
one: "նշան",
|
||||
many: "նշաններ",
|
||||
},
|
||||
verb: "ունենալ",
|
||||
},
|
||||
file: {
|
||||
unit: {
|
||||
one: "բայթ",
|
||||
many: "բայթեր",
|
||||
},
|
||||
verb: "ունենալ",
|
||||
},
|
||||
array: {
|
||||
unit: {
|
||||
one: "տարր",
|
||||
many: "տարրեր",
|
||||
},
|
||||
verb: "ունենալ",
|
||||
},
|
||||
set: {
|
||||
unit: {
|
||||
one: "տարր",
|
||||
many: "տարրեր",
|
||||
},
|
||||
verb: "ունենալ",
|
||||
},
|
||||
map: {
|
||||
unit: {
|
||||
one: "տարր",
|
||||
many: "տարրեր",
|
||||
},
|
||||
verb: "ունենալ",
|
||||
},
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "մուտք",
|
||||
email: "էլ. հասցե",
|
||||
url: "URL",
|
||||
emoji: "էմոջի",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO ամսաթիվ և ժամ",
|
||||
date: "ISO ամսաթիվ",
|
||||
time: "ISO ժամ",
|
||||
duration: "ISO տևողություն",
|
||||
ipv4: "IPv4 հասցե",
|
||||
ipv6: "IPv6 հասցե",
|
||||
mac: "MAC հասցե",
|
||||
cidrv4: "IPv4 միջակայք",
|
||||
cidrv6: "IPv6 միջակայք",
|
||||
base64: "base64 ձևաչափով տող",
|
||||
base64url: "base64url ձևաչափով տող",
|
||||
json_string: "JSON տող",
|
||||
e164: "E.164 համար",
|
||||
credit_card: "կրեդիտ քարտի համար",
|
||||
currency_code: "արժույթի կոդ",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "մուտք",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "թիվ",
|
||||
array: "զանգված",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Սխալ մուտքագրում․ սպասվում էր instanceof ${issue.expected}, ստացվել է ${received}`;
|
||||
}
|
||||
return `Սխալ մուտքագրում․ սպասվում էր ${expected}, ստացվել է ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Սխալ մուտքագրում․ սպասվում էր ${util.stringifyPrimitive(issue.values[1])}`;
|
||||
return `Սխալ տարբերակ․ սպասվում էր հետևյալներից մեկը՝ ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
const maxValue = Number(issue.maximum);
|
||||
const unit = getArmenianPlural(maxValue, sizing.unit.one, sizing.unit.many);
|
||||
return `Չափազանց մեծ արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin ?? "արժեք")} կունենա ${adj}${issue.maximum.toString()} ${unit}`;
|
||||
}
|
||||
return `Չափազանց մեծ արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin ?? "արժեք")} լինի ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
const minValue = Number(issue.minimum);
|
||||
const unit = getArmenianPlural(minValue, sizing.unit.one, sizing.unit.many);
|
||||
return `Չափազանց փոքր արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin)} կունենա ${adj}${issue.minimum.toString()} ${unit}`;
|
||||
}
|
||||
return `Չափազանց փոքր արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin)} լինի ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Սխալ տող․ պետք է սկսվի "${_issue.prefix}"-ով`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Սխալ տող․ պետք է ավարտվի "${_issue.suffix}"-ով`;
|
||||
if (_issue.format === "includes")
|
||||
return `Սխալ տող․ պետք է պարունակի "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Սխալ տող․ պետք է համապատասխանի ${_issue.pattern} ձևաչափին`;
|
||||
return `Սխալ ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Սխալ թիվ․ պետք է բազմապատիկ լինի ${issue.divisor}-ի`;
|
||||
case "unrecognized_keys":
|
||||
return `Չճանաչված բանալի${issue.keys.length > 1 ? "ներ" : ""}. ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Սխալ բանալի ${withDefiniteArticle(issue.origin)}-ում`;
|
||||
case "invalid_union":
|
||||
return "Սխալ մուտքագրում";
|
||||
case "invalid_element":
|
||||
return `Սխալ արժեք ${withDefiniteArticle(issue.origin)}-ում`;
|
||||
default:
|
||||
return `Սխալ մուտքագրում`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
import * as util from "../core/util.js";
|
||||
function getArmenianPlural(count, one, many) {
|
||||
return Math.abs(count) === 1 ? one : many;
|
||||
}
|
||||
function withDefiniteArticle(word) {
|
||||
if (!word)
|
||||
return "";
|
||||
const vowels = ["ա", "ե", "ը", "ի", "ո", "ու", "օ"];
|
||||
const lastChar = word[word.length - 1];
|
||||
return word + (vowels.includes(lastChar) ? "ն" : "ը");
|
||||
}
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: {
|
||||
unit: {
|
||||
one: "նշան",
|
||||
many: "նշաններ",
|
||||
},
|
||||
verb: "ունենալ",
|
||||
},
|
||||
file: {
|
||||
unit: {
|
||||
one: "բայթ",
|
||||
many: "բայթեր",
|
||||
},
|
||||
verb: "ունենալ",
|
||||
},
|
||||
array: {
|
||||
unit: {
|
||||
one: "տարր",
|
||||
many: "տարրեր",
|
||||
},
|
||||
verb: "ունենալ",
|
||||
},
|
||||
set: {
|
||||
unit: {
|
||||
one: "տարր",
|
||||
many: "տարրեր",
|
||||
},
|
||||
verb: "ունենալ",
|
||||
},
|
||||
map: {
|
||||
unit: {
|
||||
one: "տարր",
|
||||
many: "տարրեր",
|
||||
},
|
||||
verb: "ունենալ",
|
||||
},
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "մուտք",
|
||||
email: "էլ. հասցե",
|
||||
url: "URL",
|
||||
emoji: "էմոջի",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO ամսաթիվ և ժամ",
|
||||
date: "ISO ամսաթիվ",
|
||||
time: "ISO ժամ",
|
||||
duration: "ISO տևողություն",
|
||||
ipv4: "IPv4 հասցե",
|
||||
ipv6: "IPv6 հասցե",
|
||||
mac: "MAC հասցե",
|
||||
cidrv4: "IPv4 միջակայք",
|
||||
cidrv6: "IPv6 միջակայք",
|
||||
base64: "base64 ձևաչափով տող",
|
||||
base64url: "base64url ձևաչափով տող",
|
||||
json_string: "JSON տող",
|
||||
e164: "E.164 համար",
|
||||
credit_card: "կրեդիտ քարտի համար",
|
||||
currency_code: "արժույթի կոդ",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "մուտք",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "թիվ",
|
||||
array: "զանգված",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Սխալ մուտքագրում․ սպասվում էր instanceof ${issue.expected}, ստացվել է ${received}`;
|
||||
}
|
||||
return `Սխալ մուտքագրում․ սպասվում էր ${expected}, ստացվել է ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Սխալ մուտքագրում․ սպասվում էր ${util.stringifyPrimitive(issue.values[1])}`;
|
||||
return `Սխալ տարբերակ․ սպասվում էր հետևյալներից մեկը՝ ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
const maxValue = Number(issue.maximum);
|
||||
const unit = getArmenianPlural(maxValue, sizing.unit.one, sizing.unit.many);
|
||||
return `Չափազանց մեծ արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin ?? "արժեք")} կունենա ${adj}${issue.maximum.toString()} ${unit}`;
|
||||
}
|
||||
return `Չափազանց մեծ արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin ?? "արժեք")} լինի ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
const minValue = Number(issue.minimum);
|
||||
const unit = getArmenianPlural(minValue, sizing.unit.one, sizing.unit.many);
|
||||
return `Չափազանց փոքր արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin)} կունենա ${adj}${issue.minimum.toString()} ${unit}`;
|
||||
}
|
||||
return `Չափազանց փոքր արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin)} լինի ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Սխալ տող․ պետք է սկսվի "${_issue.prefix}"-ով`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Սխալ տող․ պետք է ավարտվի "${_issue.suffix}"-ով`;
|
||||
if (_issue.format === "includes")
|
||||
return `Սխալ տող․ պետք է պարունակի "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Սխալ տող․ պետք է համապատասխանի ${_issue.pattern} ձևաչափին`;
|
||||
return `Սխալ ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Սխալ թիվ․ պետք է բազմապատիկ լինի ${issue.divisor}-ի`;
|
||||
case "unrecognized_keys":
|
||||
return `Չճանաչված բանալի${issue.keys.length > 1 ? "ներ" : ""}. ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Սխալ բանալի ${withDefiniteArticle(issue.origin)}-ում`;
|
||||
case "invalid_union":
|
||||
return "Սխալ մուտքագրում";
|
||||
case "invalid_element":
|
||||
return `Սխալ արժեք ${withDefiniteArticle(issue.origin)}-ում`;
|
||||
default:
|
||||
return `Սխալ մուտքագրում`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "karakter", verb: "memiliki" },
|
||||
file: { unit: "byte", verb: "memiliki" },
|
||||
array: { unit: "item", verb: "memiliki" },
|
||||
set: { unit: "item", verb: "memiliki" },
|
||||
map: { unit: "item", verb: "memiliki" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "input",
|
||||
email: "alamat email",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "tanggal dan waktu format ISO",
|
||||
date: "tanggal format ISO",
|
||||
time: "jam format ISO",
|
||||
duration: "durasi format ISO",
|
||||
ipv4: "alamat IPv4",
|
||||
ipv6: "alamat IPv6",
|
||||
mac: "alamat MAC",
|
||||
cidrv4: "rentang alamat IPv4",
|
||||
cidrv6: "rentang alamat IPv6",
|
||||
base64: "string dengan enkode base64",
|
||||
base64url: "string dengan enkode base64url",
|
||||
json_string: "string JSON",
|
||||
e164: "angka E.164",
|
||||
credit_card: "nomor kartu kredit",
|
||||
currency_code: "kode mata uang",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "input",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Input tidak valid: diharapkan instanceof ${issue.expected}, diterima ${received}`;
|
||||
}
|
||||
return `Input tidak valid: diharapkan ${expected}, diterima ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Input tidak valid: diharapkan ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Pilihan tidak valid: diharapkan salah satu dari ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Terlalu besar: diharapkan ${issue.origin ?? "value"} memiliki ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemen"}`;
|
||||
return `Terlalu besar: diharapkan ${issue.origin ?? "value"} menjadi ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Terlalu kecil: diharapkan ${issue.origin} memiliki ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Terlalu kecil: diharapkan ${issue.origin} menjadi ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `String tidak valid: harus dimulai dengan "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `String tidak valid: harus berakhir dengan "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `String tidak valid: harus menyertakan "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `String tidak valid: harus sesuai pola ${_issue.pattern}`;
|
||||
return `${FormatDictionary[_issue.format] ?? issue.format} tidak valid`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Angka tidak valid: harus kelipatan dari ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Kunci tidak dikenali ${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Kunci tidak valid di ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Input tidak valid";
|
||||
case "invalid_element":
|
||||
return `Nilai tidak valid di ${issue.origin}`;
|
||||
default:
|
||||
return `Input tidak valid`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type * as errors from "../core/errors.cjs";
|
||||
declare function _default(): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
export = _default;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type * as errors from "../core/errors.js";
|
||||
export default function (): {
|
||||
localeError: errors.$ZodErrorMap;
|
||||
};
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "karakter", verb: "memiliki" },
|
||||
file: { unit: "byte", verb: "memiliki" },
|
||||
array: { unit: "item", verb: "memiliki" },
|
||||
set: { unit: "item", verb: "memiliki" },
|
||||
map: { unit: "item", verb: "memiliki" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "input",
|
||||
email: "alamat email",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "tanggal dan waktu format ISO",
|
||||
date: "tanggal format ISO",
|
||||
time: "jam format ISO",
|
||||
duration: "durasi format ISO",
|
||||
ipv4: "alamat IPv4",
|
||||
ipv6: "alamat IPv6",
|
||||
mac: "alamat MAC",
|
||||
cidrv4: "rentang alamat IPv4",
|
||||
cidrv6: "rentang alamat IPv6",
|
||||
base64: "string dengan enkode base64",
|
||||
base64url: "string dengan enkode base64url",
|
||||
json_string: "string JSON",
|
||||
e164: "angka E.164",
|
||||
credit_card: "nomor kartu kredit",
|
||||
currency_code: "kode mata uang",
|
||||
iban: "IBAN",
|
||||
jwt: "JWT",
|
||||
template_literal: "input",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Input tidak valid: diharapkan instanceof ${issue.expected}, diterima ${received}`;
|
||||
}
|
||||
return `Input tidak valid: diharapkan ${expected}, diterima ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Input tidak valid: diharapkan ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Pilihan tidak valid: diharapkan salah satu dari ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Terlalu besar: diharapkan ${issue.origin ?? "value"} memiliki ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemen"}`;
|
||||
return `Terlalu besar: diharapkan ${issue.origin ?? "value"} menjadi ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Terlalu kecil: diharapkan ${issue.origin} memiliki ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Terlalu kecil: diharapkan ${issue.origin} menjadi ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `String tidak valid: harus dimulai dengan "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `String tidak valid: harus berakhir dengan "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `String tidak valid: harus menyertakan "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `String tidak valid: harus sesuai pola ${_issue.pattern}`;
|
||||
return `${FormatDictionary[_issue.format] ?? issue.format} tidak valid`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Angka tidak valid: harus kelipatan dari ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Kunci tidak dikenali ${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Kunci tidak valid di ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Input tidak valid";
|
||||
case "invalid_element":
|
||||
return `Nilai tidak valid di ${issue.origin}`;
|
||||
default:
|
||||
return `Input tidak valid`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user