the main problem resides on validate a json against a schema that deals with arrays. So, if I put a different value seems to be still valid?
json schema:
{
"transactions" : {
"type" : "array",
"items" : {
"type" : "object",
"properties" : {
"type" : {
"type" : "string",
"enum" : ["BREAK"]
},
"required":["type"]
},
"required":["items"]
}
}
}
Input JSON:
{
"transactions":[
{
"type":"BREAKDDDDDdddddddddddddddddddddddddddJDJDJDJDJDJDJDJ"
}
]
}
result: No errors found. JSON validates against the schema.
This is wrong as we haven't defined an enum type like "BREAKDDDDD"
http://www.jsonschemavalidator.net/
Any thoughts on this?
Your JSON Schema is missing certain attributes. Look at the example provided here on how to start the schema http://json-schema.org/example1.html.
Update your schema to the below and try
{
"type": "object",
"properties": {
"transactions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["BREAK"]
}
},
"required": ["type"]
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With