Collection Rules
Validation rules for collections — schema-less records, empty records, errors.
Records without a schema
If no schema is defined, each record may have a different shape, and values are mapped to positional indices (0, 1, 2, …):
---
~ John Doe, 20, female
~ true, false
~ marketing, 123, { Z Street, Los Angeles, CA }The first record loads as { "0": "John Doe", "1": 20, "2": "female" }, and so on.
It is good practice to define a schema even though collections allow schema-less records.
Empty records
A record consisting of just ~ is an empty object ({}). It is valid only if every field in the schema is optional and/or nullable:
~ $schema: { name?*: string, age?*: { int, max: 25 } }
---
~ John, 25 # ✓
~ William # ✓ (age omitted)
~ # ✓ (empty object; all fields optional/nullable)If any field is required, an empty record fails:
~ $schema: { name: string, age?*: { int, max: 25 } }
---
~ John, 25 # ✓
~ # ✗ missing-value — name is requiredIndependent validation & error handling
Each record is validated independently. A failing record is marked as an error; the rest are unaffected:
A conformant processor SHOULD collect per-record errors and continue, rather than stopping at the first failure.
See Also
Last updated
Was this helpful?
