fix: address Copilot review round 28 — the boolean schema form in a null-admitting union
`anyOfAdmitsNull` sent every non-object member to `toBranch` and refused it,
so `{ const: null, anyOf: [true] }` read as non-nullable — a required field
seeded and rendered read-only as `null` and reported missing forever. `true`
is the unconstrained schema and admits every value, `null` among them;
`false` admits none and still does not.
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
c8c5442dcf
commit
6ac45d9b26
1 changed files with 9 additions and 0 deletions
|
|
@ -454,6 +454,9 @@ function anyOfAdmitsNull(schema: NullableUnionSchema): boolean {
|
|||
const branches = schema.anyOf;
|
||||
if (!Array.isArray(branches)) return false;
|
||||
return branches.some((entry) => {
|
||||
// JSON Schema's boolean form: `true` is the unconstrained schema and admits
|
||||
// every value, `null` among them, while `false` admits none.
|
||||
if (typeof entry === "boolean") return entry;
|
||||
const branch = toBranch(entry);
|
||||
if (branch === null) return false;
|
||||
const branchSchema = branch as NullableUnionSchema;
|
||||
|
|
|
|||
Loading…
Reference in a new issue