decode-it
Version:
a simple zero-dependency type safe json decoder for typescript
17 lines • 740 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.constructNestedErrorPath = void 0;
const typeCheckers_1 = require("./typeCheckers");
const isInnerPathAnIndex = (innerPath) => innerPath.startsWith('[');
const constructNestedErrorPath = (currentPath, innerPath) => {
const formattedCurrentPath = typeCheckers_1.isString(currentPath)
? currentPath
: `[${currentPath}]`;
return innerPath == null
? formattedCurrentPath
: isInnerPathAnIndex(innerPath)
? `${formattedCurrentPath}${innerPath}`
: `${formattedCurrentPath}.${innerPath}`;
};
exports.constructNestedErrorPath = constructNestedErrorPath;
//# sourceMappingURL=constructErrorPath.js.map