objection.js
objection.js copied to clipboard
patch validator logic does not deeply remove "required" key from jsonSchema
I ran into an issue when a jsonSchema contains nested objects with required keys. Currently, it appears that only the top-level required key is removed when using patch.
static get jsonSchema() {
return {
type: 'object',
required: ['id'],
properties: {
id: { type: 'integer' },
meta: {
type: 'object',
required: ['id2'],
properties: {
id2: { type: 'integer' },
foo: { type: 'string' }
}
}
};
Because of this, when I try to patch ["meta:foo"] = "bar", I get a validation error because id2 isn't present. I'm submitting a PR for review in a few minutes.