mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 12:56:05 +00:00
fix form isRequired utils and test
This commit is contained in:
@@ -102,7 +102,9 @@ describe("json form", () => {
|
|||||||
] satisfies [string, Exclude<JSONSchema, boolean>, boolean][];
|
] satisfies [string, Exclude<JSONSchema, boolean>, boolean][];
|
||||||
|
|
||||||
for (const [pointer, schema, output] of examples) {
|
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,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ export function isRequired(lib: Draft, pointer: string, schema: JsonSchema, data
|
|||||||
}
|
}
|
||||||
|
|
||||||
const parentPointer = getParentPointer(pointer);
|
const parentPointer = getParentPointer(pointer);
|
||||||
if (parentPointer === "" || parentPointer === "#") return false;
|
|
||||||
const parentSchema = lib.getSchema({ pointer: parentPointer, data });
|
const parentSchema = lib.getSchema({ pointer: parentPointer, data });
|
||||||
const required = parentSchema?.required?.includes(pointer.split("/").pop()!);
|
const required = parentSchema?.required?.includes(pointer.split("/").pop()!);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user