Reputation: 609
I need to validate the following: Json data: { tag: 'picture', picture: 'some string '}
Json schema: { tag: {'type': 'string'}, ??????? // The second key should be the data value of the 'tag'
Edit: I wish to accomplish this with ajv schema validator
Thank you!!
Upvotes: 0
Views: 655
Reputation: 7687
You can use $data reference (requires $data option):
{
"type": "object",
"properties": {
"tag": {"type": "string"}
},
"additionalProperties": {}, // any schema for the second property value
"propertyNames": {
"anyOf": [
{"const": "tag"},
{"const": {"$data": "1/tag"} }
]
}
}
$data is a proposal for the next versions of JSON schema.
See https://runkit.com/esp/59e0d803bf8366001374c2a2
Upvotes: 0