garycourt / JSV

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

Type checking error #24

Closed lazdmx closed 13 years ago

lazdmx commented 13 years ago

There is an error in type checking, which allows to use non-allowable values if requested type value can be taken through conversion. For example, if I have a scheme like this

{
    "type": "array",
    "items": { "type": "integer" }
}

it allows me to have instances like these: [ 42, "42", 42.0 ]

garycourt commented 13 years ago

I ran your test and JSV properly reported an error for the second item. Can not reproduce.

lazdmx commented 13 years ago

Ouch... exactly, but try this [42, 42.0]

garycourt commented 13 years ago

That will properly pass because the "integer" type only enforces that the number is divisible by one.