Evidence
An Evidence is a business flow marker attached to the type of a clean value. It is used to prove that a specific step has already been executed, without changing the business value itself.
In practice, one function can return an entity enriched with an evidence, and another function can require that exact evidence in its input type. This gives a compile-time guarantee that the first step ran before the second.
Interactive example
Syntax
appendEvidence is the function used to add an evidence.
Classic
typescript
function appendEvidence<
GenericInput extends C.AppendEvidenceInput,
GenericEvidenceName extends string
>(
input: GenericInput,
evidenceName: GenericEvidenceName,
): GenericInput & C.Evidence<GenericEvidenceName>Curried
typescript
function appendEvidence<
GenericInput extends C.AppendEvidenceInput
EvidenceName extends string
>(
evidenceName: GenericEvidenceName,
): (input: GenericInput) => GenericInput & C.Evidence<GenericEvidenceName>Parameters
input: clean value (primitive,ConstrainedType,NewType, orEntity) to enrich with an evidence.evidenceName: business name of the evidence to attach (for example"validated","authorized","loaded").
Return value
Returns the same input value, enriched with C.Evidence<evidenceName> in its type.
This marker can then be required by other functions to enforce business call ordering.
See also
flag- Add a flag on entities through a dedicated handler.useCase- Orchestrate business flows where evidences can be attached.chainedFunction- Model ordered business actions, often combined with evidence markers.
