commonjs-utils icon indicating copy to clipboard operation
commonjs-utils copied to clipboard

Item attribute doesn't validate properly

Open nicolasartman opened this issue 13 years ago • 0 comments

For example, take the following schema definition:

{ "type": "object", "properties": { "quizname": { "type": "string", "required" : true }, "scores": { "type": "object", "required" : true, "items": { "type": "integer", "required" : true, "minimum" : 0, "maximum" : 1 } } }, "additionalProperties" : false }

Then try to this with it, which should be invalid:

{
  "quizname": "quiz1",
  "scores": {"foobar":[0,1,1,1]}
}

This is invalid for a number of reasons, including: the instance value of scores is not a array, and the contents of the instance value of scores are not integers, they're objects (arrays).

I have noticed multiple other schemas containing "items" in which validation does not go as expected. I'm looking into the code to try to fix it, but in the meantime does anyone see anything wrong with my schema that would allow that bad json to get marked as valid?

nicolasartman avatar Mar 02 '11 21:03 nicolasartman