Closed 5LICK closed 4 years ago
Hi, If I try to merge schemas with "required" keyword, as result incorrect merge of "required" values.
{ "$merge": { "source": { "required": ["foo", "bar"], "properties": { "foo": { "type": "string" }, "bar": { "type": "string" } } }, "with": { "required": ["baz"], "properties": { "baz": { "type": "number" } } } } }
{ "$merge": { "source": { "required": [ "baz" ], "properties": { "foo": { "type": "string" }, "bar": { "type": "string" }, "baz": { "type": "number" } } }, "with": { "required": [ "baz" ], "properties": { "baz": { "type": "number" } } } } }
const validate = ajv.compile(schema)
validate({"foo": "asd", "bar": "asd", "baz": 123}) true validate({"foo": "asd", "baz": 123}) true validate({"baz": 123}) true validate({"foo": "asd"}) false
Ok, it seems it is global behavior of merge implementation. (close)
Indeed - you can use $patch instead - it allows modifying arrays.
Hi, If I try to merge schemas with "required" keyword, as result incorrect merge of "required" values.
Test schema
Schema after compile
Test validation
const validate = ajv.compile(schema)