fge/json-schema-validator — Issue #2: Invalid JSON is accepted by validator.
Author: nosachamos
Created: 2011-12-13 23:52:07+00:00
State: open

I had the following JSON schema defined:
{
"description" : "Example Address JSON Schema",
"type" : "object",
"properties" : {
"address" : {
"title": "Street name and number",
"type" : "string"
},
"city" : {
"title" : "City name",
"type" : "string"
},
"postalCode" : {
"title" : "Zip Code: 2 letters dash five digits",
"type" : "string",
"pattern" : "^[A-Z]{2}-[0-9]{5}"
},
"region" : {
"title" : "Optional Region name",
"type" : "string",
"optional" : true
}
},
"additionalProperties" : false
}

Then I attempted to validate the following JSON, which is invalid since non-optional property "city" is missing:

{
"address" : "happy fake address"
}

But it accepted as valid.