UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

107 lines (106 loc) 3.72 kB
import { _c as parsedType, gc as joinValues, vc as stringifyPrimitive } from "./schemas-zxit8y5H.js"; //#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/locales/en.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", 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 = parsedType(issue.input); return `Invalid input: expected ${expected}, received ${TypeDictionary[receivedType] ?? receivedType}`; } case "invalid_value": if (issue.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`; return `Invalid option: expected one of ${joinValues(issue.values, "|")}`; case "too_big": { const adj = 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.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" : ""}: ${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) return `Invalid discriminator value. Expected ${issue.options.map((o) => `'${o}'`).join(" | ")}`; return "Invalid input"; case "invalid_element": return `Invalid value in ${issue.origin}`; default: return `Invalid input`; } }; }; function en_default() { return { localeError: error() }; } //#endregion export { en_default as t };