Hi,
Was wondering if there was a way to reuse regular expressions across a JSON schema.
For example if I have a schema which defined the following types:
"name": {
"type": "string",
"pattern": "^([a-z|A-Z|0-9])+$"
}
Which allows me to define names that like "Cat1", "Dog2", "Fred"
"namespace": {
"type": "string",
"pattern": "^([a-z|0-9])+(\\.([a-z|0-9])+)*$"
},
Which allow me to define namespaces that look like this: "com.animal", "com.person"
"fully-qualified-name": {
"type": "string",
"pattern": "^(([a-z|0-9])+\\.)*([a-z|A-Z|0-9])+$"
},
Which is really a combination of the two regexps from name and namespace and allows me to define fully qualified names that look like this: "com.animal.Cat1", "com.animal.Dog2" and "com.person.Fred"
"things": {
"type": "object",
"patternProperties": {"^([a-z|0-9])+(\\.([a-z|0-9])+)*$" : {}},
"additionalProperties": false
},
Which copies the regexp for namespace and allows be to define objects that look like this:
{
"com.animal": "Dog",
"com.person": "Fred"
}
Is there a way I can structure the schema so I can reuse the regexps for name and namespace in fully-qualified-name and things schemas?
Any help would be greatly appreciated.
Regards
Rob