concrete/contract/row-rule
A member is read only through a row slot or an address in scope that offers it, and fits the slot that reads it.
A member is read only through a row slot or an address in scope that offers it, and fits the slot that reads it.
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 member of an element — a contact's phone, a comparable's price — is read only through a row declared for it. The row names which element a member comes from, so it is the one thing every field reading that element depends on. A member read from anything that is neither a row nor an address (below) has nothing it is tied to.
The row must be in scope — a field beside the reader in the same object or item, a top-level slot, or a field of a top-level object read from outside that object — and its table must offer the member. A row inside a list's item is in scope only within that item. A member's value is shown as it is, so it sits on a slot of its own type. The element itself, read whole, exists only inside an item.
An address offers its parts the same way, through the same reference: its street, unit, city, state, postal code and coordinates, and nothing derived — a one-line address is a formatting you write. Every one is read-only — a part edited alone would no longer agree with the rest of the place — and a name the address does not offer is refused with the ones it does.
Check-caught. A row's from names its table as it is declared, so the reader's
types already refuse a member it does not offer; the rule holds a schema assembled
outside the builders.
Fix
Declare a row for the element, where every reader can see it, and read its members through it under the names its table offers.
Before and after
// A comparable has no `sold_on`: the reader's types refuse the member, as the rule does.
// @noErrors
import { compute, date, fact, object, row } from "@homepages/concrete";
const comp = row({ label: "Comparable", from: fact.property.comparables });
object({
label: compute(() => "Recent sale"),
fields: { comp, sold: date({ label: "Sold", source: comp.sold_on }) },
});import { compute, date, fact, object, row } from "@homepages/concrete";
const comp = row({ label: "Comparable", from: fact.property.comparables });
object({
label: compute(() => "Recent sale"),
fields: { comp, sold: date({ label: "Sold", source: comp.sale_date }) },
});