schema-utils icon indicating copy to clipboard operation
schema-utils copied to clipboard

It accepts arrays as the object type

Open kudashevs opened this issue 4 months ago • 0 comments

  • Operating System:
  • Node Version:
  • NPM Version:
  • webpack Version:
  • schema-utils Version:

When an array is provided instead of an object, it passes the validation.

Actual Behavior

Let's take a devServer schema example from the fixtures.

let schema = '{"devServer":{"description":"Options for the webpack-dev-server","type":"object"}}';

try {
    validate(schema, []);
} catch (e) {
    console.log(e.message);
}

, and it passes the validation.

Expected Behavior

I would expect the validation error, because an object and an array are slightly different.

let schema = '{"devServer":{"description":"Options for the webpack-dev-server","type":"object"}}';

try {
    validate(schema, []);
} catch (e) {
    console.log(e.message); // schema must be object
}

Moreover, it doesn't accept an object instead of an array, and it does fail when it happens.

kudashevs avatar Oct 25 '24 20:10 kudashevs