Field Types
Field Type Overview¶
Every field has a type.
VDL supports:
- primitive types
- custom types
- enums
- arrays
- maps
- inline objects
Primitive Types¶
| VDL type | Meaning |
|---|---|
string |
Text |
int |
64-bit signed integer |
float |
64-bit floating point number |
bool |
true or false |
datetime |
ISO 8601 date-time string value |
Example:
Custom Types¶
Fields can reference other declared types.
Enum Fields¶
Fields can reference enums.
Arrays¶
Arrays use [] after the element type.
Multidimensional arrays repeat the suffix:
Maps¶
Maps use map[T], where T is the value type.
Maps can contain custom types:
Maps can also contain arrays or nested maps:
Inline Objects¶
Inline objects are anonymous structured field types.
Use inline objects when the nested shape does not need a reusable name.
Use a named type when the shape is reused or important enough to document on its own.
Optional Field Types¶
Optionality belongs to the field name, not the type.
The ? always appears after the field name.
Recursive Types¶
VDL can model recursive structures when a cycle is broken by an optional field.
Direct required cycles are rejected because they cannot be represented as finite data.
Invalid:
Make one side optional to model a nullable or absent link.