source: node_modules/@standard-schema/utils/dist/index.cjs@ ba17441

Last change on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.9 KB
Line 
1"use strict";
2var __defProp = Object.defineProperty;
3var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4var __getOwnPropNames = Object.getOwnPropertyNames;
5var __hasOwnProp = Object.prototype.hasOwnProperty;
6var __export = (target, all) => {
7 for (var name in all)
8 __defProp(target, name, { get: all[name], enumerable: true });
9};
10var __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};
18var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
20// src/index.ts
21var src_exports = {};
22__export(src_exports, {
23 SchemaError: () => SchemaError,
24 getDotPath: () => getDotPath
25});
26module.exports = __toCommonJS(src_exports);
27
28// src/getDotPath/getDotPath.ts
29function 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
50var 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:
670 && (module.exports = {
68 SchemaError,
69 getDotPath
70});
Note: See TracBrowser for help on using the repository browser.