java-json-tools / json-schema-validator

A JSON Schema validation implementation in pure Java, which aims for correctness and performance, in that order
http://json-schema-validator.herokuapp.com/
Other
1.62k stars 399 forks source link

Number 1 is accepted for enum [1.0] #283

Closed wromijn closed 5 years ago

wromijn commented 5 years ago

I was using json-schema-validator in a unit test to validate my API output format and noticed that a property of type "number" with value 1 validates against the enum [1.0]. I expected it not to validate, because 1 is not strictly equal to 1.0.

For me, the difference is important. When my API outputs 1, a client could think that the number is always integer. When it outputs 1.0 instead, they understand that it is a floating point value.

wromijn commented 5 years ago

I misunderstood the json schema specification. This behavior is correct en by design :)