UNPKG

domain-objects

Version:

A simple, convenient way to represent domain objects, leverage domain knowledge, and add runtime validation in your code base.

29 lines (28 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DomainEntityPrimaryKeysMustBeDefinedError = void 0; const helpful_errors_1 = require("helpful-errors"); // .why = an absent `static primary` is a developer misconfiguration of the class, not a caller's // bad input — so it is a MalfunctionError (exit 1, http 500), the system's fault to fix class DomainEntityPrimaryKeysMustBeDefinedError extends helpful_errors_1.MalfunctionError { constructor({ entityName, nameOfFunctionNeededFor, }) { const message = ` \`${entityName}.primary\` must be defined, to be able to \`${nameOfFunctionNeededFor}\`. Example: \`\`\` interface RocketShip { uuid?: string; serialNumber: string; fuelQuantity: number; passengers: number; } class RocketShip extends DomainEntity<RocketShip> implements RocketShip { public static primary = ['uuid']; } \`\`\` `.trim(); super(message); } } exports.DomainEntityPrimaryKeysMustBeDefinedError = DomainEntityPrimaryKeysMustBeDefinedError; //# sourceMappingURL=DomainEntityPrimaryKeysMustBeDefinedError.js.map