Skip to content

Commit e1c3023

Browse files
committed
Merge pull request #190 from vpelletier/master
Improve mutlipleOf validator with floating point value.
2 parents add447f + 2b9a722 commit e1c3023

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

jsonschema/_validators.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
from jsonschema.compat import iteritems
66

77

8-
FLOAT_TOLERANCE = 10 ** -15
9-
10-
118
def patternProperties(validator, patternProperties, instance, schema):
129
if not validator.is_type(instance, "object"):
1310
return
@@ -111,8 +108,8 @@ def multipleOf(validator, dB, instance, schema):
111108
return
112109

113110
if isinstance(dB, float):
114-
mod = instance % dB
115-
failed = (mod > FLOAT_TOLERANCE) and (dB - mod) > FLOAT_TOLERANCE
111+
quotient = instance / dB
112+
failed = int(quotient) != quotient
116113
else:
117114
failed = instance % dB
118115

0 commit comments

Comments
 (0)