Add better support for floating point multiple_of values#652
Add better support for floating point multiple_of values#652samuelcolvin merged 1 commit intopydantic:masterfrom justindujardin:bugfix/float_multiple_of
Conversation
Codecov Report
@@ Coverage Diff @@
## master #652 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 15 15
Lines 2651 2655 +4
Branches 524 526 +2
=====================================
+ Hits 2651 2655 +4 |
|
While working on this I noticed that JSONSchema spec says mutliple_of must strictly be greater than 0.0, so I added a validation error and a test for this behavior. |
|
You're checking v not Also your calling |
|
Oof, yeah. Is there a more appropriate place to check this then? Somewhere maybe it could be an error during declaration rather than at validation time? I reverted the extra validation commit for the time being. |
|
(on my mobile) Yes, they're better places, probably in |
|
@samuelcolvin FYI I'm not planning on following up with the |
|
LGTM, @justindujardin please could you rebase and move the new history line to the new section. I'm aware the history thing is getting annoying I'll try to adopt towncrier or similar soon. |
- modulo doesn't work with floating point values in many cases, e.g. `0.3 % 0.1 == 0.09999999999999998` - port implementation from: tdegrunt/jsonschema#187 (comment) - add tests for int/float multiple_of values - update history with pr/author
|
@samuelcolvin sure thing, done |
Change Summary
Add support for multiple_of with arbitrary int/floating point numbers. The current implementation fails for obvious floating point values, e.g.
0.3fails to validate as a multiple of0.1.Related issue number
None
Checklist
HISTORY.rsthas been updated#<number>@<whomever>