145 lines
6.3 KiB
JavaScript
145 lines
6.3 KiB
JavaScript
![]() |
"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: "ہونا" },
|
||
|
};
|
||
|
function getSizing(origin) {
|
||
|
return Sizable[origin] ?? null;
|
||
|
}
|
||
|
const parsedType = (data) => {
|
||
|
const t = typeof data;
|
||
|
switch (t) {
|
||
|
case "number": {
|
||
|
return Number.isNaN(data) ? "NaN" : "نمبر";
|
||
|
}
|
||
|
case "object": {
|
||
|
if (Array.isArray(data)) {
|
||
|
return "آرے";
|
||
|
}
|
||
|
if (data === null) {
|
||
|
return "نل";
|
||
|
}
|
||
|
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
||
|
return data.constructor.name;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return t;
|
||
|
};
|
||
|
const Nouns = {
|
||
|
regex: "ان پٹ",
|
||
|
email: "ای میل ایڈریس",
|
||
|
url: "یو آر ایل",
|
||
|
emoji: "ایموجی",
|
||
|
uuid: "یو یو آئی ڈی",
|
||
|
uuidv4: "یو یو آئی ڈی وی 4",
|
||
|
uuidv6: "یو یو آئی ڈی وی 6",
|
||
|
nanoid: "نینو آئی ڈی",
|
||
|
guid: "جی یو آئی ڈی",
|
||
|
cuid: "سی یو آئی ڈی",
|
||
|
cuid2: "سی یو آئی ڈی 2",
|
||
|
ulid: "یو ایل آئی ڈی",
|
||
|
xid: "ایکس آئی ڈی",
|
||
|
ksuid: "کے ایس یو آئی ڈی",
|
||
|
datetime: "آئی ایس او ڈیٹ ٹائم",
|
||
|
date: "آئی ایس او تاریخ",
|
||
|
time: "آئی ایس او وقت",
|
||
|
duration: "آئی ایس او مدت",
|
||
|
ipv4: "آئی پی وی 4 ایڈریس",
|
||
|
ipv6: "آئی پی وی 6 ایڈریس",
|
||
|
cidrv4: "آئی پی وی 4 رینج",
|
||
|
cidrv6: "آئی پی وی 6 رینج",
|
||
|
base64: "بیس 64 ان کوڈڈ سٹرنگ",
|
||
|
base64url: "بیس 64 یو آر ایل ان کوڈڈ سٹرنگ",
|
||
|
json_string: "جے ایس او این سٹرنگ",
|
||
|
e164: "ای 164 نمبر",
|
||
|
jwt: "جے ڈبلیو ٹی",
|
||
|
template_literal: "ان پٹ",
|
||
|
};
|
||
|
return (issue) => {
|
||
|
switch (issue.code) {
|
||
|
case "invalid_type":
|
||
|
return `غلط ان پٹ: ${issue.expected} متوقع تھا، ${parsedType(issue.input)} موصول ہوا`;
|
||
|
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 `غلط ${Nouns[_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;
|