jsonschema
jsonschema copied to clipboard
`Symbol` does not trigger error with `additionalProperties: false`
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 });
});