-
-
Notifications
You must be signed in to change notification settings - Fork 590
multipleOf fails validation (decimals) #247
New issue
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
Comments
Hi! Thanks. I can read this more carefully tomorrow, but from quickly glancing at that, you don't have any decimals there, you have floats. Specifically you have Apologies if my guess is wrong, just let me know if you're aware of the above. |
I understand In json there is no decimal, just integers and floats. the json schema above uses 'multipleOf' as a way to restrict the 'number' to 1 digit decimals. Although it might be possible to solve this with What would you expect jsonschema to do here ? Handle this transparantly or not ? In my case the python code doesn't mind that the actual number is a float, thats perfectly fine. I just want to be sure that the json validates against the schema. If you think json schema should handle this transparantly, the implementation of problem with using
|
when using So still open, what do you want jsonschema do, in case a python program doesn't care about how it interprets the these numbers. |
I don't see why |
Well its not the same as any other program in Python, If one wants A program that is perfectly fine with using just floats internally (as is the default) cannot rely on validating its json with What should such a program do ? First Not sure what the right approach is, but the current behaviour makes jsonschema hard to work with, if a schema has I guess this program probably arises from the fact that |
Anyone dealing with JSON needs to know that JSON does not have decimals, it has numbers, and they're generally deserialized as floats, so yeah people should be aware that if they want fixed precision, they need to parse JSON by specifying You're correct, |
I'm going to close, but if you feel strongly / disagree / want to discuss more, feel free to reopen. |
The validation of payloads using jsonschemas could fail when the payload contained a float. This problem is described in this issue: python-jsonschema/jsonschema#247 This commit implements a work around for this issue by changing the float parser for certain payloads from `float()` to `decimal.Decimal()`. Fixes: #43
The validation of payloads using jsonschemas could fail when the payload contained a float. This problem is described in this issue: python-jsonschema/jsonschema#247 This commit implements a work around for this issue by changing the float parser for certain payloads from `float()` to `decimal.Decimal()`. Fixes: #43
The validation of payloads using jsonschemas could fail when the payload contained a float. This problem is described in this issue: python-jsonschema/jsonschema#247 This commit implements a work around for this issue by changing the float parser for certain payloads from `float()` to `decimal.Decimal()`. Fixes: #43
The validation of payloads using jsonschemas could fail when the payload contained a float. This problem is described in this issue: python-jsonschema/jsonschema#247 This commit implements a work around for this issue by changing the float parser for certain payloads from `float()` to `decimal.Decimal()`. Fixes: #43
The validation of payloads using jsonschemas could fail when the payload contained a float. This problem is described in this issue: python-jsonschema/jsonschema#247 This commit implements a work around for this issue by changing the float parser for certain payloads from `float()` to `decimal.Decimal()`. Fixes: #43
The validation of payloads using jsonschemas could fail when the payload contained a float. This problem is described in this issue: python-jsonschema/jsonschema#247 This commit implements a work around for this issue by changing the float parser for certain payloads from `float()` to `decimal.Decimal()`. Fixes: mobilityhouse#43
There is a solution that convert float to Decimal in multipleOf keywords. FYI: Javascript's implement tdegrunt/jsonschema#187 PR: #1349 |
I noticed that json schemas with
multipleOf
fail to validate when using decimals.1.1 is accepted as multiple of 0.1, but 1.9 is not.
example program that demonstrates the problem
result
expected result
validation passes
version
The text was updated successfully, but these errors were encountered: