Skip to content

Instance validates if multipleOf is an integer, but fails if it's a float #1159

Open

Description

@Zac-HD
from jsonschema import validate

instance = 9007199254740995
validate(instance, schema={"type": "integer", "multipleOf": 11})    # passes
validate(instance, schema={"type": "integer", "multipleOf": 11.0})  # fails

I'm pretty sure that this is a bug, on the basis that the spec says all integer-valued numbers should be treated as integers.

Found via python-jsonschema/hypothesis-jsonschema#103.

Activity

  1. Julian commented on Sep 10, 2023

    @Julian
    Member

    Nice :)

    Needs thinking though / reading the spec language. It's true the spec says to treat floats with no fractional part as integers, but it also says (or really leaves the JSON spec to say) that floats are an acceptable implementation of number -- and I'm not sure where if anywhere covers what the requirements are on coercion to a common type.

    Specifically here, 9007199254740995 is not representable as a float, the closest float is 9007199254740996.0 which is indeed not divisible by 11, so doing the division somehow will require coercing to float.

    But it's possible you're both correct on whether this is covered by the spec and also possible this is fixable, not sure, needs thinking.

  2. Zac-HD commented on Sep 10, 2023

    @Zac-HD
    MemberAuthor

    Both passed on older versions of jsonschema, so for whatever it's worth this probably changed in version 4.18. I've just skipped the affected test though, and happy to go with your opinion 👍

  3. Julian commented on Sep 10, 2023

    @Julian
    Member
  4. added
    BugSomething doesn't work the way it should.
    on Oct 11, 2023
  5. IronAlpha3528 commented on Jan 21, 2026

    @IronAlpha3528
  6. IronAlpha3528 commented on Jan 22, 2026

    @IronAlpha3528
  7. added a commit that references this issue on Feb 24, 2026
    08a8c22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething doesn't work the way it should.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions