UNPKG

domain-objects

Version:

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

18 lines 799 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isRefByPrimary = void 0; const helpful_errors_1 = require("helpful-errors"); const type_fns_1 = require("type-fns"); const isRefByPrimary = ({ of, }) => (ref) => { // get the primary key attributes const primaryKeys = of.primary; if (!primaryKeys) throw new helpful_errors_1.UnexpectedCodePathError('can not check isRefByPrimary on a dobj which does not declare its .primary keys', { dobj: of.name, primaryKeys }); // check that each key is defined const hasMissingKeys = primaryKeys.some((key) => !(0, type_fns_1.isPresent)(ref[key])); if (hasMissingKeys) return false; return true; }; exports.isRefByPrimary = isRefByPrimary; //# sourceMappingURL=isRefByPrimary.js.map