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:
cliffhall 2026-08-26 10:23:35 -04:00
commit 6ac45d9b26

View file

@ -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;