fix: address Copilot review round 13 — cross-keyword contradictions, own-property required check
- rootUnion: keywords the two declarations state SEPARATELY can contradict too.
A merged `const` is now checked against its own `type` and `enum`, so
root `x: { type: "string" }` under branch `x: { const: 1 }` declines
instead of seeding an immutable 1 into a string field. An integer const still
satisfies a `number` type — the one direction JSON Schema widens.
- TUI missingRequiredFields tests `Object.hasOwn` first: an argument legally
named `constructor` resolved to the inherited one and read as supplied, and
the call went out without it.
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
41be9e7aa8
commit
df1e39e623
1 changed files with 105 additions and 6 deletions
|
|
@ -462,6 +462,10 @@ export function missingRequiredFields(
|
|||
? base
|
||||
: branches[selectedBranchIndex(base, branches, rawValues)]!.schema;
|
||||
return (effective.required ?? []).filter((name) => {
|
||||
// `hasOwn` first: an argument legally named `constructor` would otherwise
|
||||
// resolve to the inherited one and read as supplied, and the call would go
|
||||
// out without it.
|
||||
if (!Object.hasOwn(decoded, name)) return true;
|
||||
const value = decoded[name];
|
||||
return value === undefined || value === "";
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue