UNPKG

zod-error

Version:

Utilities to format and customize Zod error messages

19 lines (18 loc) 689 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getBreadcrumbs = void 0; /** * Adds breadcrumbs to a path. * Delimiter defaults to >. * @export * @param {z.ZodIssue['path']} path * @param {Breadcrumbs} options * @return {*} {string} */ function getBreadcrumbs(path, options) { var _a, _b; const arraySquareBrackets = (_a = options.arraySquareBrackets) !== null && _a !== void 0 ? _a : true; const delimeter = (_b = options.delimeter) !== null && _b !== void 0 ? _b : ' > '; return path.map((key) => (typeof key === 'number' && arraySquareBrackets ? `[${key}]` : key)).join(delimeter); } exports.getBreadcrumbs = getBreadcrumbs;