jsonschema-rs
jsonschema-rs copied to clipboard
multipleOF validation for non integer values
Validating multipleOf values non integer values is problematic. It can be argued if this is a bug or a logical result of how floats work, but the result below will probably surprise many users.
>>> import jsonschema_rs
>>> (
... jsonschema_rs.JSONSchema({"multipleOf": 0.1}).is_valid(1.1),
... jsonschema_rs.JSONSchema({"multipleOf": 0.1}).is_valid(10.1)
... )
(True, False)
Of course caused by floating point issues:
>>> 10.1 - (101 * 0.1)
-1.7763568394002505e-15
If/how this validates or fails differs amongst a few different implementations I tried. So don't know if there really is a fundamentally correct option. But at least some other validators accept this, so I wanted make you aware if the differences. Related to #84, See also https://github.com/Julian/jsonschema/pull/878