fix form isRequired utils and test

This commit is contained in:
dswbx
2025-08-14 16:56:12 +02:00
parent 9e0eaf42e5
commit aafd333d12
2 changed files with 3 additions and 2 deletions

View File

@@ -102,7 +102,9 @@ describe("json form", () => {
] satisfies [string, Exclude<JSONSchema, boolean>, boolean][];
for (const [pointer, schema, output] of examples) {
expect(utils.isRequired(new Draft2019(schema), pointer, schema)).toBe(output);
expect(utils.isRequired(new Draft2019(schema), pointer, schema), `${pointer} `).toBe(
output,
);
}
});

View File

@@ -73,7 +73,6 @@ export function isRequired(lib: Draft, pointer: string, schema: JsonSchema, data
}
const parentPointer = getParentPointer(pointer);
if (parentPointer === "" || parentPointer === "#") return false;
const parentSchema = lib.getSchema({ pointer: parentPointer, data });
const required = parentSchema?.required?.includes(pointer.split("/").pop()!);