diff --git a/src/ValidationError.js b/src/ValidationError.js index cec8556..1fe4e4f 100644 --- a/src/ValidationError.js +++ b/src/ValidationError.js @@ -234,7 +234,11 @@ function canApplyNot(schema) { * @returns {boolean} */ function isObject(maybeObj) { - return typeof maybeObj === "object" && maybeObj !== null; + return ( + typeof maybeObj === "object" && + !Array.isArray(maybeObj) && + maybeObj !== null + ); } /** diff --git a/test/__snapshots__/index.test.js.snap b/test/__snapshots__/index.test.js.snap index b970055..ea19e0f 100644 --- a/test/__snapshots__/index.test.js.snap +++ b/test/__snapshots__/index.test.js.snap @@ -1524,6 +1524,13 @@ exports[`Validation should fail validation for object in object with anyOf 1`] = [object { alias?, name?, onlyModule? }, ...]" `; +exports[`Validation should fail validation for object type 1`] = ` +"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. + - configuration.devServer should be an object: + object { … } + -> Options for the webpack-dev-server" +`; + exports[`Validation should fail validation for object with dependencies #2 1`] = ` "Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. - configuration.objectWithPropertyDependency2 should be an object: diff --git a/test/index.test.js b/test/index.test.js index 764a04a..83cabf0 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -771,6 +771,14 @@ describe("Validation", () => { (msg) => expect(msg).toMatchSnapshot() ); + createFailedTestCase( + "object type", + { + devServer: [], + }, + (msg) => expect(msg).toMatchSnapshot() + ); + createFailedTestCase( "array type", {