We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Code example
schema = <<~JSON { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "amount": { "type": "number", "multipleOf": 0.01 } }, "additionalProperties": false } JSON JSONSchemer.schema(schema).valid?({ "amount" => 8.61 }) #=> false
I expect the JSON data to be valid.
The problematic part of the the code is validate_numeric because it treats the numbers as floats.
validate_numeric
The text was updated successfully, but these errors were encountered:
Use BigDecimal for multiple_of check
BigDecimal
multiple_of
ff7a4ba
Floats aren't accurate enough here. Fixes: #100 Also addresses overflow exposed by: json-schema-org/JSON-Schema-Test-Suite#438 ``` FloatDomainError: Infinity /Users/dharsha/repos/json_schemer/lib/json_schemer/schema/base.rb:367:in `floor' /Users/dharsha/repos/json_schemer/lib/json_schemer/schema/base.rb:367:in `validate_numeric' /Users/dharsha/repos/json_schemer/lib/json_schemer/schema/base.rb:378:in `validate_number' /Users/dharsha/repos/json_schemer/lib/json_schemer/schema/base.rb:277:in `validate_type' /Users/dharsha/repos/json_schemer/lib/json_schemer/schema/base.rb:198:in `validate_instance' ```
Thanks for the issue @legendetm! Should be fixed in 0.2.20
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Code example
I expect the JSON data to be valid.
The problematic part of the the code is
validate_numeric
because it treats the numbers as floats.The text was updated successfully, but these errors were encountered: