concrete/contract/count-bounds
The items a fill is asked for fit the min and max of the list that holds them, at the top level or inside an item.
The items a fill is asked for fit the min and max of the list that holds them, at the top level or inside an item.
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
How many items a list holds is declared once, on the list: its min and max bound
every source, a fill included, and no fill takes a count. A section built by a
Concrete older than 9.0 may still carry a count on its decision — the number of
items the fill asked for, beside the bounds of the slot or row field holding them.
Nothing made the two agree, so they are compared here.
A literal count: N is exact, so it is a floor as well as a ceiling; a range states
its own floor and ceiling.
Three disagreements are errors rather than variance. A request whose ceiling is above
the holder's max spends a larger model call whose overflow is dropped, invisibly. A
request whose floor is above that max can never be satisfied. And a request whose
ceiling is below the holder's min guarantees the slot renders under its own declared
minimum. A request that MAY land short — a floor under the minimum with a ceiling at
or above it — is the model's discretion, not an authoring fault, and passes.
A range whose min is above its own max is rejected whatever holds it: no answer
fits inside it.
The comparison runs at every level a count can be written: the produced slot for the
list's own count, and each planned field's own declaration for its. A count on a
slot that holds one value, or on a list sourced by a table, whose items are the
table's rows, counts nothing, so it is refused rather than ignored.
Check-caught, and only reachable from a stored section: the fill verbs refuse count
by type, and throw on it at runtime.
Fix
Drop the count and bound the list with its own
min and max — a filled list declares max. Rebuilding the section with the
current Concrete does exactly that.
Before and after
// A fill took a `count` before 9.0; this half is that stored shape, and today's builders refuse it.
// @noErrors
import { fact, fill, list, text } from "@homepages/concrete";
list({
label: "Features",
max: 4,
source: fill({
reads: [fact.property.description],
brief: "The features this unit has, each a short noun phrase.",
count: 6,
}),
item: text.short({ label: "Feature", cap: 80 }),
});import { fact, fill, list, text } from "@homepages/concrete";
list({
label: "Features",
max: 6,
source: fill.write({
reads: [fact.property.description],
brief: "The features this unit has, each a short noun phrase.",
}),
item: text.short({ cap: 80 }),
});