Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol does not trigger error with additionalProperties: false #348

Open
gabssnake opened this issue Jul 8, 2021 · 0 comments
Open

Symbol does not trigger error with additionalProperties: false #348

gabssnake opened this issue Jul 8, 2021 · 0 comments

Comments

@gabssnake
Copy link

Hi there, thank you for your good work !

It seems additionalProperties which have a Symbol key do not throw with throwError.

What am I doing wrong? Is this expected behavior?

const assert = require("assert").strict;
const validate = require("jsonschema").validate;

const schema = {
  type: "object",
  properties: {
    msg: { type: "string" }
  },
  additionalProperties: false
};

// Missing expected exception
assert.throws(() => {
  validate({ msg: "hello", [Symbol("stealth")]: "oops" }, schema, { throwError: true });
});

assert.doesNotThrow(() => {
  validate({ msg: "hello" }, schema, { throwError: true });
});

assert.throws(() => {
  validate({ msg: "hello", extra: "boom" }, schema, { throwError: true });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant