I want to describe a network graph of vertices and edges with JSON Schema.
An example JSON could look like this:
{
"V": [
"1",
"2",
"3"
],
"E": [
{
"v1": "1",
"v2": "2"
},
{
"v1": "2",
"v2": "3"
}
]
}
I have a set of 3 vertices and 2 edges to connect them. I want all vertices to have an arbitrary string identifier, so it could also be "node1" or "panda". However, is there a way to validate that the endpoints of my edges only point to existing vertices?
I.e.: Should NOT pass:
{
"V": [
"n1",
"n2",
"n3"
],
"E": [
{
"v1": "n1",
"v2": "IdThatDoesNotExistAbove"
}
]
}
I looked at ENUMs, however, I struggle to have them point at data from a JSON that I want to validate rather than to the specification itself.