UNPKG

domain-objects

Version:

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

35 lines 1.74 kB
"use strict"; var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.DomainLiteral = exports.MARK_AS_DOMAIN_LITERAL = void 0; const DomainObject_1 = require("./DomainObject"); const markers_1 = require("./markers"); const version_1 = require("./version"); var markers_2 = require("./markers"); Object.defineProperty(exports, "MARK_AS_DOMAIN_LITERAL", { enumerable: true, get: function () { return markers_2.MARK_AS_DOMAIN_LITERAL; } }); /** * In Domain Driven Design, a Literal (a.k.a. Value Object), is a type of Domain Object for which: * - properties are immutable * - i.e., it represents some literal value which happens to have a structured object shape * - i.e., if you change the value of any of its properties, it is a different literal * - identity does not matter * - i.e., it is uniquely identifiable by its non-metadata properties * * The purpose of a Domain Literal is to represent distinct, literal values which happen to have a structured object shape * * For example, * - A `Address { street, city, state, country }` is a literal. Changing any of the properties, like `street`, produces a completely new address * - A `Geocode { latitude, longitude }` is a literal. Changing either property means you are dealing with a new geocode */ class DomainLiteral extends DomainObject_1.DomainObject { } exports.DomainLiteral = DomainLiteral; _a = markers_1.MARK_AS_DOMAIN_LITERAL; /** * DomainLiteral marker symbol for cross-version compatibility. * * Uses Symbol.for() to create a global symbol that works across different versions * of the domain-objects library. The value is the version string. */ DomainLiteral[_a] = version_1.VERSION; //# sourceMappingURL=DomainLiteral.js.map