Skip to content

multipleOf for floats result in false validation errors #158

@gmkeith

Description

@gmkeith

Given a schema like the following:
"salary": {
"type": "number",
"multipleOf": 0.01
}
and the value 10000.51.
The validation returns a false validation error. This appears to be due to floating point precision errors of the modulus operator used. This error may appear for any number < 1 and > 0.

I'm happy to create a fix and pull request for this. Due to the nature of the error it may require adding a dependency like http://jsfromhell.com/classes/bignumber, https://github.com/josdejong/mathjs or something similar as floating point calculations tend to quite complex problems to solve.

Let me know
Thanks
Glenn

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