value-object¶
Typed, named structural definition without identity. See Concepts: Value Object.
Fields¶
| Field | Required | Description |
|---|---|---|
apiVersion |
yes | schema.esdm.io/core/v1 |
kind |
yes | value-object |
name |
yes | The Value Object name. |
scope |
yes | scope.boundedContext reference. |
schema |
yes | JSON Schema describing the Value Object's shape. |
invariants |
no | Named rules over the Value Object's data. |
description |
no | Free-form prose. |
metadata |
no | Non-semantic labels and annotations. |
The field is named schema (a type definition), in contrast to event.data and command.data (a payload value).
Example¶
apiVersion: schema.esdm.io/core/v1
kind: value-object
name: money-amount
scope:
domain: golf-club-management
boundedContext: round-play
schema:
type: object
properties:
amount: { type: number, minimum: 0 }
currency: { type: string, pattern: "^[A-Z]{3}$" }
required: [amount, currency]
invariants:
- name: non-negative-amount
rule: A `money-amount` cannot be negative.