garycourt / JSV

A JavaScript implementation of an extendable, fully compliant JSON Schema validator.
618 stars 84 forks source link

Problem with "enum" #12

Closed rmzelle closed 13 years ago

rmzelle commented 13 years ago

Using JSV through vickeryj's validator_form.html, I have a problem with the following JSON schema and JSON:

JSON schema: http://pastebin.com/3f7H6yDT

JSON: http://pastebin.com/rPhR7rym

The schema only allows "letter" to be set to "a" or "b", but doesn't catch the value of "c" on the second object in the array. Setting the value of "letter" of the first object to "c" does result in a validation error, as expected.

garycourt commented 13 years ago

Your JSON Schema is using tuple typing, so only the first item in the array will be validated. I have corrected your example here: http://pastebin.com/QegcbQGq

rmzelle commented 13 years ago

Thanks. Sorry for the noise.