| [a762898] | 1 | "use strict";
|
|---|
| 2 | var __defProp = Object.defineProperty;
|
|---|
| 3 | var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|---|
| 4 | var __getOwnPropNames = Object.getOwnPropertyNames;
|
|---|
| 5 | var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|---|
| 6 | var __export = (target, all) => {
|
|---|
| 7 | for (var name in all)
|
|---|
| 8 | __defProp(target, name, { get: all[name], enumerable: true });
|
|---|
| 9 | };
|
|---|
| 10 | var __copyProps = (to, from, except, desc) => {
|
|---|
| 11 | if (from && typeof from === "object" || typeof from === "function") {
|
|---|
| 12 | for (let key of __getOwnPropNames(from))
|
|---|
| 13 | if (!__hasOwnProp.call(to, key) && key !== except)
|
|---|
| 14 | __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|---|
| 15 | }
|
|---|
| 16 | return to;
|
|---|
| 17 | };
|
|---|
| 18 | var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|---|
| 19 |
|
|---|
| 20 | // src/index.ts
|
|---|
| 21 | var src_exports = {};
|
|---|
| 22 | __export(src_exports, {
|
|---|
| 23 | SchemaError: () => SchemaError,
|
|---|
| 24 | getDotPath: () => getDotPath
|
|---|
| 25 | });
|
|---|
| 26 | module.exports = __toCommonJS(src_exports);
|
|---|
| 27 |
|
|---|
| 28 | // src/getDotPath/getDotPath.ts
|
|---|
| 29 | function getDotPath(issue) {
|
|---|
| 30 | if (issue.path?.length) {
|
|---|
| 31 | let dotPath = "";
|
|---|
| 32 | for (const item of issue.path) {
|
|---|
| 33 | const key = typeof item === "object" ? item.key : item;
|
|---|
| 34 | if (typeof key === "string" || typeof key === "number") {
|
|---|
| 35 | if (dotPath) {
|
|---|
| 36 | dotPath += `.${key}`;
|
|---|
| 37 | } else {
|
|---|
| 38 | dotPath += key;
|
|---|
| 39 | }
|
|---|
| 40 | } else {
|
|---|
| 41 | return null;
|
|---|
| 42 | }
|
|---|
| 43 | }
|
|---|
| 44 | return dotPath;
|
|---|
| 45 | }
|
|---|
| 46 | return null;
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | // src/SchemaError/SchemaError.ts
|
|---|
| 50 | var SchemaError = class extends Error {
|
|---|
| 51 | /**
|
|---|
| 52 | * The schema issues.
|
|---|
| 53 | */
|
|---|
| 54 | issues;
|
|---|
| 55 | /**
|
|---|
| 56 | * Creates a schema error with useful information.
|
|---|
| 57 | *
|
|---|
| 58 | * @param issues The schema issues.
|
|---|
| 59 | */
|
|---|
| 60 | constructor(issues) {
|
|---|
| 61 | super(issues[0].message);
|
|---|
| 62 | this.name = "SchemaError";
|
|---|
| 63 | this.issues = issues;
|
|---|
| 64 | }
|
|---|
| 65 | };
|
|---|
| 66 | // Annotate the CommonJS export names for ESM import in node:
|
|---|
| 67 | 0 && (module.exports = {
|
|---|
| 68 | SchemaError,
|
|---|
| 69 | getDotPath
|
|---|
| 70 | });
|
|---|