New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help us to solve issues with validation #49
Comments
Hi - could you please post an example schema, and some data that you believe should fail? It'd be easier to tackle the problem if I have an example of the bug. :) |
My sample JSON Schema and data as follows for validating var schema ={
"type":"object",
"required":false,
"properties":{
"fieldElement": {
"type":"object",
"required":false,
"properties":{
"readonly": {
"type":"boolean",
"required":true
},
"caption": {
"type":"string",
"required":false
}
}
},
"fieldType": {
"type":"string",
"required":false
}
}
};
data = {
"fieldType": "text",
"fieldElement": {
"caption": "textfield",
"readonly": true
}
}; In this case this will work Case 1 As per the Schema the 'readonly' property is a required field. But When I removed the fieldElement ->readonly from data and try to validate, the result will be true. data = {
"fieldType": "textfield",
"fieldElement": {
"caption": "textfield"
}
}; Case 2 As per the Schema the 'caption' is there as a property. But When I changed the 'caption' to 'caption12345' in data and try to validate, the result will be true. The sample data as follows, data = {
"fieldType": "textfield",
"fieldElement": {
"caption12345": "textfield",
"readonly": true
}
}; |
Ah - the issue is your use of In version 4 of the JSON Schema specification (which Here is a modified version of your schema with the correct |
OK, thank you for your Advice :) |
The {
"type":"object",
"properties":{
"$ref": {
"type":"string",
"format": "uri"
}
}
} With the above schema, it correctly checks the type of |
Thanks for your Help, But in my case the schema as follows schema ={
"type":"object",
"required":false,
"properties":{
"fieldElement": {
"type":"object",
"required":false,
"properties":{
"readonly": {
"type":"boolean",
"required":true
},
"caption": {
"$ref": "../../../../common.schema.caption.json"
},
}
},
"fieldType": {
"type":"string",
"required":false
}
}
}; The caption property had a ref path ( "../../../../common.schema.caption.json ) and the details for caption will take from that particular JSON Schema. Thanks |
Have you supplied that "common.schema.caption.json" schema to If a After validation, what is the value of |
After validation the ref URLs comes in 'tv4.missing' array Actually in ''../../../../common.schema.caption.json' which contains a json schema { the schema contains schema with ref URL (common.schema.caption.json) Can you please help us to solve this, Is this the right method? or Do i miss something? |
Well, Do you have a line like: |
Assuming closed. |
Hi, |
When we validate our JSON against JSON Schema its get validated successfully.But in this cases we have noted two issues in your script
1,If we removed a mandatory key/value pair from json no error displayed ( Actually we need to display an error like " Key value pair is missing in json " like some online validators)
2,If we alter the key name no error should be raised.We need to raise some error like invalid JSON
The text was updated successfully, but these errors were encountered: