Concrete
Rulescontract

concrete/contract/select

A select names its choices in exactly one place: its values, or a fact it is bound to that declares them.

A select names its choices in exactly one place: its values, or a fact it is bound to that declares them.

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

A select gets its choices from exactly one place: a written-out from array, or a fact binding whose field domain IS the set. Declaring both, or neither, leaves the editor with no single answer to what the dropdown offers.

A select bound to a fact offers the choices the fact declares, and only some facts declare choices. Binding a select to one that declares none leaves the editor an empty option list: a dropdown the user cannot open, with nothing reported at publish, at render or in the console.

The first half is type-caught in practice: the builder's types admit from or a fact source:, never both and never neither, so what reaches this rule is a schema assembled outside the builders. Which facts declare choices is not part of fact.*'s type, so the second half is check-caught.

A creatable select's keys need no particular spelling. The editor stores a value a user creates exactly as they typed it, and text that differs from an option's key or label only in case or spacing picks that option instead of creating a second spelling of it.

Fix

Declare exactly one of from or a fact source:, and bind a fact that declares its choices, such as fact.property.listing_intent. To offer choices of your own over a fact that declares none, write them out as from.

Before and after

// A slot assembled by hand, outside the builders: no `from`, no `source`.
const features = { type: "select", label: "Building features" };
import { select } from "@homepages/concrete";

select({ label: "Building features", from: ["Pet friendly", "Doorman"], creatable: true });
import { fact, select } from "@homepages/concrete";

select({ source: fact.property.address.city, label: "City" });
import { fact, select } from "@homepages/concrete";

select({ source: fact.property.listing_intent, label: "Listing status" });

On this page