Skip to content

Commit a5a1584

Browse files
committed
🐛 Do NOT allow Array for isObjectOf
1 parent a5fd925 commit a5a1584

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

is/factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ export function isObjectOf<
563563
}
564564
return setPredicateFactoryMetadata(
565565
(x: unknown): x is ObjectOf<T> => {
566-
if (x == null || typeof x !== "object") return false;
566+
if (x == null || typeof x !== "object" || Array.isArray(x)) return false;
567567
// Check each values
568568
for (const k in predObj) {
569569
if (!predObj[k]((x as T)[k])) return false;

is/factory_test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,11 @@ Deno.test("isObjectOf<T>", async (t) => {
687687
false,
688688
"Specify `{ strict: true }` and object have an unknown property",
689689
);
690+
assertEquals(
691+
isObjectOf({ 0: isString })(["a"]),
692+
false,
693+
"Value is not an object",
694+
);
690695
});
691696
await t.step("returns true on T instance", () => {
692697
const date = new Date();

0 commit comments

Comments
 (0)