@clickup/ent-framework
Version:
A PostgreSQL graph-database-alike library with microsharding and row-level security
23 lines • 964 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.maybeThrowEntValidationError = maybeThrowEntValidationError;
const EntValidationError_1 = require("../../errors/EntValidationError");
function maybeThrowEntValidationError({ name, field, res, allowRichResult, }) {
if (typeof res === "boolean") {
return res;
}
const issues = "issues" in res ? res.issues : "error" in res ? res.error?.issues : [];
if (issues?.length) {
throw new EntValidationError_1.EntValidationError(name, issues.map(({ message, path }) => ({
field: path
?.map((part) => (typeof part === "object" ? part.key : part))
.join(".") || field,
message,
})));
}
if (allowRichResult) {
return true;
}
throw Error("BUG: validator must return true, false or one of Validator*Result values");
}
//# sourceMappingURL=maybeThrowEntValidationError.js.map
;