fix: address Copilot review round 41 — const does not demand a property, required-only branches
- `const` constrains a property that is PRESENT; it neither requires the
property nor acts as a default. It is now supplied automatically only where
the schema also requires the field — in `collectSchemaDefaults`,
`applySchemaConstants` and the TUI's initial values alike — so an optional
`dryRun: { const: true }` no longer turns a valid `{}` call into one that
asks the server to do something. A value that IS present is still corrected
to the constant, whatever supplied it, and the field stays read-only.
- Offerability is judged on the base+member merge rather than the raw member,
so `anyOf: [{ required: ["email"] }, { required: ["phone"] }]` over
root-declared properties is offered. It was declined, which left the gate
checking the base alone and accepting `{}` — which that schema rejects.
- The TUI's branch sections keep the schema's own `required` for the seeding
decision while still rendering every branch field non-required, which is what
keeps a static form submittable.
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
8f935adaad
commit
b0b252a5c0
1 changed files with 167 additions and 22 deletions
|
|
@ -2344,6 +2344,7 @@ describe("SchemaForm multiline strings (#2042)", () => {
|
|||
a: { type: "string", title: "A" },
|
||||
version: { type: "string", const: "2" },
|
||||
},
|
||||
required: ["version"],
|
||||
}}
|
||||
values={{}}
|
||||
onChange={onChange}
|
||||
|
|
@ -2402,6 +2403,7 @@ describe("SchemaForm multiline strings (#2042)", () => {
|
|||
kind: { type: "string", const: value },
|
||||
note: { type: "string", title: "Note" },
|
||||
},
|
||||
required: ["kind"],
|
||||
});
|
||||
const { rerender } = renderWithMantine(
|
||||
<SchemaForm
|
||||
|
|
|
|||
Loading…
Reference in a new issue