-
-
Notifications
You must be signed in to change notification settings - Fork 208
add float truncation #278
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
add float truncation #278
Conversation
|
I would support only strings: |
|
There isn't any concept of "rounding" defined in the spec https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.2 |
|
so you think the default behavior should be to throw if it's not an integer? |
|
I believe that is the consensus we reached the last time we discussed how to handle non-spec compliant values (i.e. |
|
I would actually prefer to not do anything in this case if we want to throw. |
|
Looking over this again, it seems this PR is making use of an undocumented second parameter to the |
|
Yes, this pr doesn't force the user to add non-spec fields to the input schema. This pr force the type coertion of those properties defined by user as "integer" The second parameter is documented to add external schemas and debug the stringify function, but I agree on a follow up pr to document better this option that is spread across the readme and I will take care of it 👍🏼 |
|
Are there any concerns for this PR? |
mcollina
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Fix #277
Note that to implement a
roundinginput option the most straightforward way is to generate the output function calling a global named function.In this case the input would be the ugly (note the Math.round as 'string`):
Or:
Where
Which one do you think would be better? Or do you see nicest solutions?
Checklist
npm run testandnpm run benchmarkand the Code of conduct