Open & Dynamic Schemas
Open and dynamic schemas — accepting extra fields with the * marker.
Closed by default
~ $schema: { name: string, age: int }
---
~ John, 30 # ✓
~ Alex, 25, extra1 # ✗ additional-values-not-allowedAllowing extra fields with *
*~ $schema: { name: string, age: int, * }
---
~ John, 30 # ✓
~ Alex, 25, Male, cool # ✓ extras at index 2 and 3
~ { Mia, 28, role: dev } # ✓ extra keyed field "role"Typing the extra fields
Dynamic types with anyOf
When to use curly braces
See Also
Last updated
Was this helpful?
