Description
Sorry, I can't find any better place to ask and I can't find any examples. It looks like $merge would do it but according to issue #15, this wont be included.
My use case, I have an Person
object in a schema file with a firstName
and lastName
requires firstName
.
I need an Employee
object in a separate schema. I want it to inherit Person
and add the property company
and require the company
property.
A valid Person
:
{
"firstName": "Bob",
"lastName": "Smith"
}
An invalid Person
:
{
"firstName": "Bob"
}
A invalid Person
:
{
"firstName": "Bob",
"lastName": "Smith",
"foo": "bar"
}
A valid Employee
:
{
"firstName": "Bob",
"lastName": "Smith",
"company": "ABC Inc."
}
An invalid Employee
:
{
"firstName": "Bob",
"lastName": "Smith",
"company": "ABC Inc.",
"foo": "bar"
}
A invalid Employee
:
{
"firstName": "Bob",
"company": "ABC Inc."
}
I'd like to end up with two schema files, Person.schema.json
and Employee.schema.json
. Where a Person
object or and Employee
object would pass Person.schema.json
validation, a Person
object would not necessarily pass Employee.schema.json
validation.