Skip to content

Commit cee0056

Browse files
committed
Allow nested checking
1 parent 7c961fa commit cee0056

3 files changed

Lines changed: 178 additions & 54 deletions

File tree

lib/entry-points.js

Lines changed: 88 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/json/index.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,24 @@ test("validateSchema - validates objects", async (t) => {
103103
t.false(json.validateSchema(objectSchema, { objectKey: 123 }));
104104
});
105105

106+
const checkSchemaTestSchema = {
107+
rootKey: json.object(objectSchema),
108+
};
109+
106110
test("validateSchema - checkSchema reports unknown keys", async (t) => {
107-
const result = json.checkSchema(testSchema, {
108-
requiredKey: "foo",
111+
const result = json.checkSchema(checkSchemaTestSchema, {
112+
rootKey: {
113+
objectKey: {
114+
arrayKey: [],
115+
},
116+
nestedExtraKey: "foo",
117+
},
109118
extraKey: "bar",
110119
});
111120

112121
t.true(result.valid);
113-
t.deepEqual(result.unknownKeys, ["extraKey"]);
122+
t.deepEqual(
123+
result.unknownKeys.sort(),
124+
["extraKey", "rootKey.nestedExtraKey"].sort(),
125+
);
114126
});

0 commit comments

Comments
 (0)