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: "to have" }, | |
| file: { unit: "바이트", verb: "to have" }, | |
| array: { unit: "개", verb: "to have" }, | |
| set: { unit: "개", verb: "to have" }, | |
| }; | |
| 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" : "number"; | |
| } | |
| case "object": { | |
| if (Array.isArray(data)) { | |
| return "array"; | |
| } | |
| if (data === null) { | |
| return "null"; | |
| } | |
| if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) { | |
| return data.constructor.name; | |
| } | |
| } | |
| } | |
| return t; | |
| }; | |
| const Nouns: { | |
| [k in $ZodStringFormats | (string & {})]?: string; | |
| } = { | |
| 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 주소", | |
| cidrv4: "IPv4 범위", | |
| cidrv6: "IPv6 범위", | |
| base64: "base64 인코딩 문자열", | |
| base64url: "base64url 인코딩 문자열", | |
| json_string: "JSON 문자열", | |
| e164: "E.164 번호", | |
| jwt: "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 suffix = adj === "미만" ? "이어야 합니다" : "여야 합니다"; | |
| const sizing = getSizing(issue.origin); | |
| const unit = sizing?.unit ?? "요소"; | |
| if (sizing) return `${issue.origin ?? "값"}이 너무 큽니다: ${issue.maximum.toString()}${unit} ${adj}${suffix}`; | |
| return `${issue.origin ?? "값"}이 너무 큽니다: ${issue.maximum.toString()} ${adj}${suffix}`; | |
| } | |
| case "too_small": { | |
| const adj = issue.inclusive ? "이상" : "초과"; | |
| const suffix = adj === "이상" ? "이어야 합니다" : "여야 합니다"; | |
| const sizing = getSizing(issue.origin); | |
| const unit = sizing?.unit ?? "요소"; | |
| if (sizing) { | |
| return `${issue.origin ?? "값"}이 너무 작습니다: ${issue.minimum.toString()}${unit} ${adj}${suffix}`; | |
| } | |
| return `${issue.origin ?? "값"}이 너무 작습니다: ${issue.minimum.toString()} ${adj}${suffix}`; | |
| } | |
| 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 `인식할 수 없는 키: ${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:
- 4.71 kB
- Xet hash:
- 0151de5a89364b163cd2a927b5a6fde5d31c3c7d6722900ac86d3fdc49390b8f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.