Skip to content

multipleOF validation for non integer values #315

@tdamsma

Description

@tdamsma

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions