Skip to content
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

schema of number is float64 #280

Open
Tracked by #318
Tevic opened this issue Dec 30, 2020 · 1 comment
Open
Tracked by #318

schema of number is float64 #280

Tevic opened this issue Dec 30, 2020 · 1 comment

Comments

@Tevic
Copy link
Contributor

Tevic commented Dec 30, 2020

// Number
Min        *float64 `json:"minimum,omitempty" yaml:"minimum,omitempty"`
Max        *float64 `json:"maximum,omitempty" yaml:"maximum,omitempty"`
MultipleOf *float64 `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"`

I can see the schema of number is float64, and the default json decoder marshal number into float64, however there will be precision problems between float64 and int64, so the validation may not be correct.

@fenollp
Copy link
Collaborator

fenollp commented Dec 31, 2020

Indeed! I plan on moving schema validation to https://github.com/xeipuuv/gojsonschema which takes proper care of this using Reals.
Now I'm wondering whether all float64 field should actually be reals. I don't think any JSON Schema Draft specifies a precision (and just assumes that of the js runtime). I know this was discussed and the above mentioned repo. So this will surely follow that discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants