schema = { "type" : "object",
"properties" :
{ "price" : {"type" : "array",
"items" : { "type" : "string" , "pattern": "^[A-Za-z0-9_]*$" }},
},
}
from jsonschema import validate
validate(instance={"price" : ["test","34"]}, schema=schema)
The above code validates the property price having non spaced string array items. Is it possible to validate the property even if we don't know the incoming property name ?
Possibly like below
schema = { "type" : "object",
"properties" :
{ "type" : "array",
"items" : { "type" : "string" , "pattern": "^[A-Za-z0-9_]*$" },
},
}
from jsonschema import validate
validate(instance={"price" : ["test","34"]}, schema=schema)
validate(instance={"marks" : ["test","34"]}, schema=schema)