Julian/jsonschema — pull request #190 by vpelletier (2014-12-29 15:30:30+00:00)
Title: Improve mutlipleOf validator with floating point value.

Example:
>>> 150.0 % 0.01
0.009999999999996878
>>> 0.01 - 0.009999999999996878
3.1225022567582528e-15
>>> 150.0 / 0.01
15000.0

I've prepared a commit against json-schema/JSON-Schema-Test-Suite adding following test case:
{
"schema": {"multipleOf": 0.01},
"tests": [
{
"description": "150.0 is multiple of 0.01",
"data": 150.0,
"valid": true
},
{
"description": "150.0001 is not multiple of 0.01",
"data": 150.0001,
"valid": false
}
]
}
but am not sure it is the right place to put such test nor how to choose "better" values without relying on implementation (does implementatio use modulo ? on double or single precision ? etc). As a result, I could not come up with a meaningful description. Anyway, this test fails with current implementation with:
ValidationError: 150.0 is not a multiple of 0.01
and is fixed with attached patch.