I am struggling to get a simple definition for audio and video. The format should be of the form,
"audio": "These are mp3 artifacts" or
"digital": "These are .mp4 or .wav files"
I attempted as described in the documentation, using patternProperties with a regex which validates in a regex engine, like this, but it did not work.
{
"$schema": "https://json-schema.org/draft-07/schema#",
"description": "Definitions common to all most schemas",
"type": "object",
"additionalProperties":false,
"Definitions": {
"type": "object",
"patternProperties": {
"digital|audio": {"type": "string"}
},
"title": "Definitions"
}
}
CodePudding user response:
You have an extra "Definitions" object. See https://json-schema.org/understanding-json-schema/reference/object.html#pattern-properties. This should work:
{
"$schema": "https://json-schema.org/draft-07/schema#",
"type": "object",
"additionalProperties": false,
"patternProperties": {
"digital|audio": {
"type": "string"
}
}
}