Entity / foldkit-entity

DeclaredInvariant

interface · packages/entity/src/invariant.ts:119

interface DeclaredInvariant<E extends AnyEntity> {
  (entity: E): E
  readonly id: string
  readonly entity: string
}

An invariant as declared: the step that attaches it to its Entity, carrying its id and, once attached, that Entity's name, so a refusal is matched against the declaration rather than a string spelled again (Refusal.isInvalidBy(refusal, reservedWithinQuantity)). An id is unique only within an Entity, so the name is part of what a refusal names; reading it before the declaration is attached throws.

Members

DeclaredInvariant.id

property · packages/entity/src/invariant.ts:121

readonly id: string

DeclaredInvariant.entity

property · packages/entity/src/invariant.ts:122

readonly entity: string