One form for every type
Every type is declared the same way, type Name = Base { ... }. The base
says what the type is built from, and the block holds the details: rules for
a number or text, fields for an object, variants for an enum. An entity is
declared on its own, because it is more than a type: it is stored, and it has
actions, queries and policy (Data).
type ItemPrice = Decimal { // rules on a number scale: 2 min: 0.00}type StockCode = Text { // rules on text pattern: "[A-Z]{3}-[0-9]{4}"}type OrderId = Uuid {} // a new identity type with no extra rulestype OrderLine = Object { // fields sku: StockCode price: ItemPrice}type OrderStatus = Enum { // variants pending paid shipped}type PaymentOutcome = Enum { // variants that carry fields pending paid: { receipt_id: ReceiptId } declined: { reason: DeclineReason }}type CreateOrder = Input { // an object arriving from outside lines: List<OrderLineRequest> note: OrderNote { optional: true }}type OrderView = Output { // an object sent back id: Order.id total: ItemPrice}
Object,Enum,InputandOutputare only ever used as a base here. There is no anonymous object written inline; every shape has a name.Inputobjects may haveoptionalanddefaultfields and are the only objects a route accepts.Outputobjects are the only objects a route returns.- There are no
value,enum,inputoroutputkeywords, and thetypes/folder holds onlytypedeclarations.
Markdown for agents: /docs/one-form-for-every-type.md.Built from Jadpo main at a707efb.