diff --git a/lib/options.json b/lib/options.json index 554f8fe48d..d546d03f37 100644 --- a/lib/options.json +++ b/lib/options.json @@ -523,7 +523,8 @@ "type": "number" }, { - "type": "string" + "type": "string", + "minLength": 1 }, { "enum": ["auto"] diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index a69d352d81..a4f107f387 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -414,25 +414,30 @@ exports[`options validate should throw an error on the "open" option with '{"tar * configuration.open.target should be a non-empty string." `; +exports[`options validate should throw an error on the "port" option with '' value 1`] = ` +"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. + - configuration.port should be an non-empty string." +`; + exports[`options validate should throw an error on the "port" option with 'false' value 1`] = ` "ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. - configuration.port should be one of these: - number | string | \\"auto\\" + number | non-empty string | \\"auto\\" -> Specify a port number to listen for requests on. https://webpack.js.org/configuration/dev-server/#devserverport Details: * configuration.port should be a number. - * configuration.port should be a string. + * configuration.port should be a non-empty string. * configuration.port should be \\"auto\\"." `; exports[`options validate should throw an error on the "port" option with 'null' value 1`] = ` "ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. - configuration.port should be one of these: - number | string | \\"auto\\" + number | non-empty string | \\"auto\\" -> Specify a port number to listen for requests on. https://webpack.js.org/configuration/dev-server/#devserverport Details: * configuration.port should be a number. - * configuration.port should be a string. + * configuration.port should be a non-empty string. * configuration.port should be \\"auto\\"." `; diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index a69d352d81..a4f107f387 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -414,25 +414,30 @@ exports[`options validate should throw an error on the "open" option with '{"tar * configuration.open.target should be a non-empty string." `; +exports[`options validate should throw an error on the "port" option with '' value 1`] = ` +"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. + - configuration.port should be an non-empty string." +`; + exports[`options validate should throw an error on the "port" option with 'false' value 1`] = ` "ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. - configuration.port should be one of these: - number | string | \\"auto\\" + number | non-empty string | \\"auto\\" -> Specify a port number to listen for requests on. https://webpack.js.org/configuration/dev-server/#devserverport Details: * configuration.port should be a number. - * configuration.port should be a string. + * configuration.port should be a non-empty string. * configuration.port should be \\"auto\\"." `; exports[`options validate should throw an error on the "port" option with 'null' value 1`] = ` "ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. - configuration.port should be one of these: - number | string | \\"auto\\" + number | non-empty string | \\"auto\\" -> Specify a port number to listen for requests on. https://webpack.js.org/configuration/dev-server/#devserverport Details: * configuration.port should be a number. - * configuration.port should be a string. + * configuration.port should be a non-empty string. * configuration.port should be \\"auto\\"." `; diff --git a/test/validate-options.test.js b/test/validate-options.test.js index c5db1a006e..c6e37b72c2 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -258,8 +258,8 @@ const tests = { failure: ['', [], { foo: 'bar' }, { target: 90 }, { app: true }], }, port: { - success: ['', 0, 'auto'], - failure: [false, null], + success: ['8080', 8080, 'auto'], + failure: [false, null, ''], }, proxy: { success: [