Skip to content

Field Types

Field Types

MashinTalk fields are typed. Types appear in accepts (input contract), responds with (output contract), returns (step output schema), and resource fields (store definitions). The type system is shared across all contexts, with some modifiers specific to stores (see Store Field Types).

When to use

Every field declaration needs a type. Choose the most specific type that matches your data: use integer over number when you know the value is always whole, use enum(...) when the value is one of a fixed set, use decimal for financial amounts where precision matters.

Syntax

<field_name> as <type>, <modifiers>

Primitive types

TypeDescriptionExample values
textText value. The primary string type."hello", "[email protected]"
stringAlias for text. Both compile identically."hello"
numberNumeric value (integer or floating point). Use when you do not need to distinguish between them.42, 3.14
integerWhole number only.0, 42, -7
decimalPrecise decimal. No floating-point rounding errors. Use for currency, measurements, scores.19.99, 0.001
booleanTrue or false.true, false
uuidUUID identifier string. Typically used for primary keys."550e8400-e29b-41d4-a716-446655440000"
dateCalendar date without time. ISO 8601 format."2026-04-29"
datetimeDate and time in UTC. ISO 8601 format."2026-04-29T14:30:00Z"

Composite types

TypeDescriptionExample
listList of any values.[1, "two", true]
list(<type>)Typed list. All elements must match the inner type.list(text), list(integer)
mapKey-value map with string keys and any values.{key: "value", count: 42}
objectAlias for map. Both compile identically.{name: "test"}
object { ... }Structured object with named, typed fields. Provides schema validation for nested data.See examples below.
enum("a", "b", "c")One of a fixed set of string values. Values are validated on input."draft", "active", "archived"
anyAny type. No type validation. Use sparingly.Any value.

File types

TypeDescriptionExample
fileAny file. Content-addressed reference.Binary data reference
file(image)Image file (any image mime type).PNG, JPEG, WebP
file(image/png | image/jpeg)Image restricted to specific formats.PNG or JPEG only
file(application/pdf)PDF file.PDF document
file(text)Plain text file.TXT, CSV

File-specific modifiers

ModifierDescriptionExample
max_size: <size>Maximum file sizemax_size: 25mb
max_pages: <n>Maximum page count (PDFs)max_pages: 100
max_dimensions: <w>x<h>Maximum image dimensionsmax_dimensions: 8000x8000

Special types

TypeDescriptionExample
machine_refType-safe reference to another machine. Can include schema constraints.See examples below.

Field modifiers

ModifierDescriptionExample
is requiredField must be provided. Cannot be nil.name as text, is required
default: <value>Default value if the field is not provided.count as integer, default: 0

Examples

Input contract with mixed types

machine data_processor
accepts
query as text, is required
limit as integer, default: 10
include_metadata as boolean, default: false
categories as list(text)
options as map
responds with
results as list
total as integer
query_time as decimal

Enum for fixed-value fields

accepts
priority as enum("low", "medium", "high", "critical"), is required
status as enum("open", "in_progress", "resolved"), default: "open"

Enum values are validated at input. Passing a value not in the set produces a validation error.

Nested objects

accepts
address as object { street as text, is required; city as text, is required; state as text; zip as text }
contact as object { name as text, is required; email as text; phone as text }

Nested objects define an inline schema for structured data. Each field inside the object follows the same name as type, modifiers syntax, separated by semicolons.

File inputs

accepts
receipt as file(image), is required, max_size: 25mb
report as file(application/pdf), max_pages: 100
attachment as file

File fields are content-addressed references. The actual bytes are stored once and referenced everywhere. The behavioral ledger stores file metadata (id, content_hash, mime_type, size), never the raw bytes.

Machine references

accepts
handler as machine_ref, is required
processor as machine_ref, accepts { text: string }, returns { result: string }

A machine_ref is a type-safe reference to another machine. You can optionally constrain the referenced machine’s input and output schemas. Machine references enable dynamic dispatch: passing different machines as arguments to achieve different behaviors.

Store resource fields

resource product
id as uuid, is primary_key
name as text, is required
price as decimal, is required
quantity as integer, default: 0
tags as list(text)
metadata as map
status as enum("draft", "active", "discontinued"), default: "draft"
timestamps

Store fields support the full type system plus store-specific modifiers like is primary_key, column:, and timestamps. See Store Field Types.

Type coercion

MashinTalk applies minimal type coercion at input boundaries:

  • String "42" is coerced to 42 for integer and number fields
  • String "true" / "false" is coerced to true / false for boolean fields
  • ISO 8601 strings are parsed for date and datetime fields

Inside compute step expressions, values are used as-is. No implicit coercion occurs within the expression language.

Governance

Types are structural declarations. They do not involve runtime governance. However, types are part of the machine’s contract and serve several governance purposes:

  • Input types are validated before execution starts. Invalid inputs produce a validation error before any steps run.
  • Output types are checked after execution. If the machine’s output does not match its declared schema, the execution fails.
  • Type information is recorded in the behavioral ledger as part of the execution trace.
  • File types track provenance (content hashes, mime types, sizes) in the ledger.

Translations

Types are not translated. They use the same names in all locales. The as keyword and the is modifier keyword are translated:

Languageasis required
Englishasis required
Spanishcomoes requerido
Frenchcommeest requis
Germanalsist erforderlich
Japaneseとして必須
Chinese作为必填
Korean으로필수

See also