Skip to content

Defining schemas

Every block on the Designer canvas has a shape: the fields of a command, an event, or a State View. Designer defines those shapes in EvidentSchema, a subset of CUE.

  • Constraints live with the types. A field can be a string that must match a pattern, or one of a fixed set of values, not just “a string”.
  • Types compose. Define a timestamp or an identifier once, and use it in every event that carries one.
  • It exports to JSON Schema, so other tools can read the same shapes.

From a TodoMVC model:

// ISO 8601 timestamp
Timestamp: string & =~"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})$"
// String identifiers (non-empty enforced by pattern)
TodoId: string & =~"^.+$"
TodoTitle: string & =~"^.+$"
TodoCreated: {
type: "todo.created"
todoId: TodoId
title: TodoTitle
effectiveTimestamp: Timestamp
}

Select a block, and edit its schema in the sidebar’s schema editor. The editor highlights EvidentSchema, and marks errors inline as you type.

You can also give example data, in JSON. Designer checks it against the schema, so you can see that the shape accepts the data you expect, and refuses the data you don’t.

When you generate code, each schema becomes a Rust type in the project’s domain crate, with serde derives for serialization.