diff --git a/packages/core/src/__tests__/validate-config.test.ts b/packages/core/src/__tests__/validate-config.test.ts index ec5effed3..16b125d38 100644 --- a/packages/core/src/__tests__/validate-config.test.ts +++ b/packages/core/src/__tests__/validate-config.test.ts @@ -466,18 +466,22 @@ describe("validatePlugin", () => { } }); - // Check no validation issues with base options expect( await validatePlugins(hook, { plugins: [["test-plugin", { url: "foo" }]], }) ).toStrictEqual([]); - // Check no validation issues with intersected options expect( await validatePlugins(hook, { plugins: [["test-plugin", { auth: "app" }]], }) ).toMatchSnapshot(); + // Check no validation issues with intersected options + expect( + await validatePlugins(hook, { + plugins: [["test-plugin", { auth: "app", channels: ['foo'] }]], + }) + ).toStrictEqual([]); }); test("should validate plugin configuration - array of configurations", async () => { diff --git a/packages/core/src/validate-config.ts b/packages/core/src/validate-config.ts index 6d52a6cd1..726024360 100644 --- a/packages/core/src/validate-config.ts +++ b/packages/core/src/validate-config.ts @@ -256,17 +256,16 @@ export const validateIoConfiguration = ( type._tag === "IntersectionType" || (type as any)._tag === "ExactType" ) ) { - const matchingMember = exactDeclaration.types - .map((t) => t.decode(rc)) - .filter((t) => "left" in t)[0]; + const decodedTypes = exactDeclaration.types.map((t) => t.decode(rc)); + const matchingMissingMember = decodedTypes.filter((t) => "left" in t)[0]; - if (matchingMember && "left" in matchingMember) { + if (matchingMissingMember && "left" in matchingMissingMember) { const correct = Object.keys( - matchingMember.left[0].context[0].actual as any + matchingMissingMember.left[0].context[0].actual as any ); const missing = - matchingMember.left[0].context[ - matchingMember.left[0].context.length - 1 + matchingMissingMember.left[0].context[ + matchingMissingMember.left[0].context.length - 1 ].key; return [ @@ -277,6 +276,17 @@ export const validateIoConfiguration = ( )} you must also provide ${unexpectedValue(missing)}\n`, ]; } + + const matchingCorrectMember = decodedTypes.filter( + (t) => + "right" in t && + Object.keys(t.right).length && + Object.keys(t.right).every((key) => unknownKeys.includes(key)) + )[0]; + + if (matchingCorrectMember) { + return []; + } } return [