Concrete
Rulescontract

concrete/contract/nested-slot-types

An object's fields, a nested list item's included, are each a value slot, a row or a list, of a kind the catalog declares.

An object's fields, a nested list item's included, are each a value slot, a row or a list, of a kind the catalog declares.

Graded by the contracts stage of concrete check, in the contract venue. A violation reports this id and the file it failed at — see every rule and concrete check.

Reason

An object's fields are one level deep: each is a value slot, a row, a list of value slots, or a list of objects — never an object, and never a list of rows — so every field the editor, the fill and the renderer reach is addressed by one flat four-part tuple (the instance, the slot, the item, the field), with no fifth part to reach through. A list of objects is one field, its items part of that field's value, and their own fields are checked here too. The same holds wherever the object sits: at a section's top level, as a list's item, or as the item of an object's list of objects.

Within that depth, a field is a slot like any other, and the platform renders, edits and fills each one by its kind. A field carrying a kind the catalog does not declare is a value nothing knows what to do with: the editor has no control to draw for it, the fill has no planner to reach for, and the renderer has no binding to hand the section. This rule holds that half — the kind — and contract/object the shape.

The walk is keyed on the declared fields rather than on a type name, so every object is checked — at a section's top level, as a list's item, as the item of an object's list of objects, and as the fields record a section built by a Concrete older than 9.0 stored — and a record found by name alone would pass this gate vacuously. A row is the one field beside the catalog's value kinds, since a row is how an object reads an element's members.

Type-caught. An object's fields are built by the slot builders, each of which emits its own kind, so there is no spelling to get wrong; a hand-written field object is refused by the field's own type. The rule holds a schema assembled outside the builders, which is what publishing re-runs the contract venue over.

Fix

Build every field with a slot builder — see list for what a list's item may hold.

Before and after

// The hand-written field is the violation, so this half is not expected to compile.
// @noErrors
import { fact, fill, list, object, text } from "@homepages/concrete";

list({
  label: "People",
  max: 4,
  source: fill.write({
    reads: [fact.property.description],
    brief: "Everyone named on the listing, by full name.",
  }),
  item: (name) =>
    object({
      label: name,
      fields: {
        badge: { type: "chip", label: "Badge" },
      },
    }),
});
import { fact, fill, list, object, select, text } from "@homepages/concrete";

list({
  label: "People",
  max: 4,
  source: fill.write({
    reads: [fact.property.description],
    brief: "Everyone named on the listing, by full name.",
  }),
  item: (name) =>
    object({
      label: name,
      fields: {
        badge: select({
          label: "Badge",
          from: ["owner", "agent"],
          source: fill.pick({ reads: [fact.property.description, name], unique: false, brief: "Whether the person owns the property or represents it." }),
        }),
      },
    }),
});

On this page