domain-objects
Version:
A simple, convenient way to represent domain objects, leverage domain knowledge, and add runtime validation in your code base.
25 lines (24 loc) • 903 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HelpfulJoiValidationError = void 0;
class HelpfulJoiValidationError extends Error {
constructor({ error, props, domainObject, }) {
const details = error.details.map((detail) => ({
message: detail.message,
path: detail.path.join('.'),
type: detail.type,
}));
const message = `
Errors on ${Object.keys(details).length} properties were found while validating properties for domain object ${domainObject}.:
${JSON.stringify(details, null, 2)}
Props Provided:
${JSON.stringify(props, null, 2)}
`.trim();
super(message);
this.details = details;
this.props = props;
this.domainObject = domainObject;
}
}
exports.HelpfulJoiValidationError = HelpfulJoiValidationError;
//# sourceMappingURL=HelpfulJoiValidationError.js.map