Skip to content

0.0 is not considered an integer in draft-04 schemas #705

@Zac-HD

Description

@Zac-HD

I discovered this oddity working on a hypothesis-jsonschema upgrade:

from jsonschema import validate
validate(0.0, {"type": "integer"})  # passes
validate(0.0, {"type": "integer", "$schema": "http://json-schema.org/draft-04/schema#"})  # fails

The first behaviour is correct, because the "integer" 'type' is defined by having a zero fractional part, rather than by the Python type of the value. (a surprise which my planned feature will introduce to users...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions