Buckets:
| import type { $ZodStringFormats } from "../core/checks.js"; | |
| import type * as errors from "../core/errors.js"; | |
| import * as util from "../core/util.js"; | |
| const error: () => errors.$ZodErrorMap = () => { | |
| const Sizable: Record<string, { unit: string; verb: string }> = { | |
| string: { unit: "حروف", verb: "ہونا" }, | |
| file: { unit: "بائٹس", verb: "ہونا" }, | |
| array: { unit: "آئٹمز", verb: "ہونا" }, | |
| set: { unit: "آئٹمز", verb: "ہونا" }, | |
| }; | |
| function getSizing(origin: string): { unit: string; verb: string } | null { | |
| return Sizable[origin] ?? null; | |
| } | |
| const parsedType = (data: any): string => { | |
| 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: { | |
| [k in $ZodStringFormats | (string & {})]?: string; | |
| } = { | |
| 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 as errors.$ZodStringFormatIssues; | |
| 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 `غلط ان پٹ`; | |
| } | |
| }; | |
| }; | |
| export default function (): { localeError: errors.$ZodErrorMap } { | |
| return { | |
| localeError: error(), | |
| }; | |
| } | |
Xet Storage Details
- Size:
- 5.02 kB
- Xet hash:
- 6ea4ca2e06388e804806d8cb5ed32b7262e62f294e451e88291cbdfc9b2be1ee
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.