Skip to content

Commit b1d035b

Browse files
committed
docs(plugin-form): the currency-scale report's prose says both validators judge a declared subform column now (objectui#11266)
reportCurrencyColumnScale's docblock and the currencyScale-10783 test header and one test name said a subform's columns is z.array(z.any()) in the object-form mirror and in the spec's FormViewSchema, and that the spec does not judge that path. This PR makes the mirror half false, and @objectstack/spec 17.6.0 already made the spec half false: both now judge a declared column with InlineGridColumnSchema. The reason the render-time report exists is restated truthfully: neither zod face sees an identity-only { name, scale } column whose child field is a currency, only defineStack does at publish (objectstack#20927), and nothing runs either validator between a stored or code-built form view and the render. Comment and test-name bytes only; the TS printer with removeComments shows no other change. Claude-Session: https://claude.ai/code/session_01CPvhwGcirXqBGEdPSb72TZ Co-authored-by: Claude <noreply@anthropic.com>
1 parent ce55b46 commit b1d035b

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

‎packages/plugin-form/src/deriveMasterDetail.currencyScale-10783.test.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
* `@objectstack/spec` 17.5.0 refuses `scale` on an inline grid column that
1515
* declares `type: 'currency'`. A column that declares no `type`
1616
* (`{ name: 'amount', scale: 2 }`) still parses: `hydrateColumns` fills its
17-
* `type` from the child field at render time, which the spec cannot see, and
18-
* `objectui validate` cannot either (a subform's `columns` is
19-
* `z.array(z.any())`, and the child object's fields are not in the document).
17+
* `type` from the child field at render time. The spec's column schema cannot
18+
* see that, and `objectui validate` cannot either: it judges a subform's
19+
* `columns` with that same schema (objectui#11266), and the child object's
20+
* fields are not in the document. Only `defineStack` refuses it, at publish, by
21+
* resolving `name` against the child object the stack declares
22+
* (objectstack-ai/objectstack#20927); nothing in objectui does.
2023
* `GridField`'s `currencyWidth` no longer reads a currency column's `scale`, so
2124
* without a report here the key would be accepted everywhere and read by
2225
* nothing.
@@ -69,7 +72,7 @@ describe('hydrateColumns reports a `scale` on a column that hydrates to currency
6972
expect(computeRow(cols, { quantity: 3, unit_price: 1.2345 }, 'KWD').amount).toBe(3.704);
7073
});
7174

72-
it('a declared currency column carrying `scale` is reported too (the form-view `subforms[].columns` path the spec does not judge)', () => {
75+
it('a declared currency column carrying `scale` is reported too (a stored or code-built form view reaches the render without passing either validator)', () => {
7376
const warnings = spyWarn();
7477
hydrateColumns([{ name: 'amount', type: 'currency', computed: true, expr: 'quantity * unit_price', scale: 2 }], lineSchema('line_declared'));
7578
const reports = warnings().filter((m) => m.includes('`scale`'));

‎packages/plugin-form/src/deriveMasterDetail.ts‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,22 @@ export function deriveColumns(
296296
* docblock says the reach stops there: an identity-only entry
297297
* (`{ name: 'amount', scale: 2 }`) takes its type from the child field at
298298
* render time, here, so it still parses. `objectui validate` cannot see it
299-
* either: a subform's `columns` is `z.array(z.any())` in the `object-form`
300-
* mirror, and the child object's fields are not in the document it judges.
301-
* This is the first place the child field is known, so the report is made
302-
* here — ⛔ never a silent drop.
299+
* either: the `object-form` mirror judges a subform's `columns` with the spec's
300+
* own `InlineGridColumnSchema` (objectui#11266), and the child object's fields
301+
* are not in the document it judges. Only `defineStack` refuses it, at publish, by resolving
302+
* `name` against the child object's fields: on a relationship field's
303+
* `inlineColumns` and on a form view's `subforms[].columns`, and only when the
304+
* stack declares that child object (objectstack-ai/objectstack#20927). Nothing
305+
* in objectui does that, and this is the first place in objectui the child
306+
* field is known, so the report is made here — ⛔ never a silent drop.
303307
*
304-
* The declared arm is reported too. A form view's `subforms[].columns` is
305-
* `z.array(z.any())` in the spec's `FormViewSchema`, so a typed currency column
306-
* carrying `scale` reaches this function unjudged on that path.
308+
* The declared arm is reported too. On a form view's `subforms[].columns` both
309+
* validators refuse a typed currency column carrying `scale`: the spec's
310+
* `FormViewSchema` holds each column to `InlineGridColumnSchema` from 17.6.0,
311+
* and the `object-form` mirror takes that schema by reference (objectui#11266).
312+
* Neither runs between a stored or code-built form view and this function, so
313+
* such a column can still arrive here, and it is reported rather than read in
314+
* silence.
307315
*
308316
* Once per column per page load (the `sectionFields.ts` convention): this runs
309317
* on every child-schema resolve. The first sentence is the spec's refusal with

0 commit comments

Comments
 (0)