Root Schema:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"deviceId": {
"description": "Unique ID of the device of type UUIDv4",
"type": "string",
"format": "uuid"
}
},
"required": ["deviceId"]
}
Json validation properly reports error for below below input, as uuid is invalid
{
"deviceId" : "410c75b4"
}
However the validator does not report any error, if below are the inputs.
Input Json Data:
""
"1234"
0
As per my understanding root schema specifically says that deviceId
is the required
json input, but still json validator successfully validates empty string, random string or some number against the json schema.
Python code
try:
validate(instance=jsoninput, schema=rootschema, format_checker=jsonschema.FormatChecker())
except Exception as err:
print(f'Validation failed: {err}')
return False
Also tested here https://www.jsonschemavalidator.net/