-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
is 1.0
an "integer"?
#132
Comments
Discussion had over on spec issue: json-schema-org/json-schema-spec#79 (comment) |
It appears we already had this discussion in #22, but we're re-evaluating this on new evidence that the spec says |
Looks like it's either changing the test, or removing the "mathmatically" similar clause. |
(I've been pretty swamped the last 2 weeks, so apologies for long turnarounds on all these issues) -- but yeah that test was submitted by @fge, who authored the spec at the time, so I'm inclined to believe it's probably the correct interpretation. I can go back and read all the comments (and the spec) hopefully in the next day or two. |
@awwright: It looks to me like the spec says they SHOULD not be equal (admittedly a less severe requirement than MUST). 3.5:
5.5:
EDIT: Links changed to go to draft 4 instead of latest. |
Hum. That's a good argument. Maybe the "mathmatically the same" is meant to represent 1.0 and 1.0000 should be considered the same. |
I've looked into this a little more. However, |
In the latest draft, there's no differentiation between "integer" and "number" as a primitive type anymore; and as of current master "integer" is simply defined as "any number with a zero fractional part". Is there any reason this doesn't work? The only reason I can think of that we want this, is for things like user IDs and serial numbers, where it makes little sense representing the number in a form like But that is a parser-level concern, which JSON Schema specifically doesn't cover. Should that be reconsidered? |
@awwright: I think it's subjective. According to the JSON specification, This sounds crazy, but might even have been a useful thing to do! Deciding whether we want to distinguish Further thoughtsFor a quantity that's not divisible |
Assume for the moment we want to modify JSON Schema... We could modify the "number" primitive to include two numeric values, "value" and "precision" or something. Then "integer" would be any number with a precision of exactly 1 (a.k.a. e0) -- leaving out |
Actually, I like this idea -- an optional feature for parsers that do want to distinguish between precision. I think I'll file an enhancement for this. You may have stumbled across something, @seagreen Edit: Filed json-schema-org/json-schema-spec#152 |
Filed json-schema-org/json-schema-spec#152 I think I'll close this, resolved with: The current definition (an integer is any number with a zero fractional part) suffices, and pretty much any other case can be handled by the new feature. |
Right now, draft-04 says:
However, the test suite has this test: https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/develop/tests/draft4/optional/zeroTerminatedFloats.json
meaning that even though
1.0
is equal to1
, there still exists a keyword where one will validate and the other will not.Should this be correct? I don't see any language in draft-04 for why this should be the case. I suggest remove this test, or flip the test result to "valid".
The text was updated successfully, but these errors were encountered: