Groundwork in core¶
Core's data definitions cannot state some facts a description needs: a default, example values, a label for each allowed choice, and rules that depend on another key. The groundwork adds them to Typed Data, validation and the Field API.
A module states these facts itself for the keys it declares in Portable Schema. The groundwork is for modules with no Portable Schema definitions of their own, whose keys are read from core's definitions: their config schema and their field definitions. Many contributed modules will change nothing and be read this way for a long time, so what their definitions can state decides how good their forms, Tool API tools and endpoints are. The groundwork happens alongside the rest of the path, and neither waits for the other.
Each change pays off alone. Core already derives JSON Schema from definitions, so a definition that states its default shows it there with no other change.
Rules that depend on another key¶
| Kind | Example | Core today | With the groundwork |
|---|---|---|---|
| A fixed condition: while one key has a certain value, another is required or limited | A ticket needs a price when pricing is "paid" | Form API's #states, which only the browser reads, and code in validateForm() |
The definition states the condition, validation enforces it, and the JSON Schema says it as if/then |
| A list looked up from another key | The bundles offered depend on the entity type | Often only a form's #ajax callback |
The definition names the keys it depends on. The lookup itself stays in code |
A condition can only make a rule stricter, so a reader that ignores it is looser, never wrong.
Where it stands¶
Three items are in core's queue: defaults (#3620920), examples (#3620922), and constraints written as JSON Schema keywords (#3627330). The rest are drafted in the proof of concept's core gaps, where each is working code today.