Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multipleOF validation for non integer values #315

Open
tdamsma opened this issue Nov 5, 2021 · 0 comments
Open

multipleOF validation for non integer values #315

tdamsma opened this issue Nov 5, 2021 · 0 comments

Comments

@tdamsma
Copy link

tdamsma commented Nov 5, 2021

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 python-jsonschema/jsonschema#878

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant