bpdusk / jsonschema

Automatically exported from code.google.com/p/jsonschema
0 stars 0 forks source link

Tuple types not validated properly when using additionalProperties restriction #16

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create schema:
{
    "type": "array",
    "items": [{"type": "string"}, {"type": "integer"}],
    "additionalItems": {"type": "object"}
}
and an instance:
["abc", 123, "def"]

2. Attempt to validate the instance using the schema.

What is the expected output? What do you see instead?

Expected: An object indicating the instance is invalid according to the schema.
Instead: The returned object indicates the instance is valid.

What version of the product are you using? On what operating system?

jsonschema-b4.js, Firefox 3.5.1, Windows Vista

Please provide any additional information below.

My solution is on lines 142-152 of the attached file jsonschema-b4.2.js.
Note that additionalProperties is changed to additionalItems in this
solution.  Simply changing it back to additionalProperties would bring the
implementation back into conformance with the proposal.

Attached Files

jsonSchemaTest.html (My test html file)
jsonschema-b4.2.js (The implementation modified with the solution to this
issue, another issue I posted, a modification of the additionalProperties
to additionalItems restriction, as well as some other modifications for
personal preference which don't affect conformance to the JSON Schema proposal)

Original issue reported on code.google.com by swessits...@gmail.com on 3 Aug 2009 at 10:50

Attachments: