| "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: "to have" }, |
| file: { unit: "바이트", verb: "to have" }, |
| array: { unit: "개", verb: "to have" }, |
| set: { unit: "개", verb: "to have" }, |
| }; |
| function getSizing(origin) { |
| return Sizable[origin] ?? null; |
| } |
| const parsedType = (data) => { |
| 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 = { |
| 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; |
| 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 `잘못된 입력`; |
| } |
| }; |
| }; |
| function default_1() { |
| return { |
| localeError: error(), |
| }; |
| } |