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.
Why a schema language
Section titled “Why a schema language”- 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.
What a schema looks like
Section titled “What a schema looks like”From a TodoMVC model:
// ISO 8601 timestampTimestamp: 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}Defining them in Designer
Section titled “Defining them in Designer”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.
What the schemas become
Section titled “What the schemas become”When you generate code, each schema becomes a Rust type in the project’s domain crate, with serde derives for serialization.