-
-
Notifications
You must be signed in to change notification settings - Fork 325
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
Floating point when using multipleOf #379
Comments
Nice issue, you're totally right, it should generate a two-decimal number instead. So much thanks for your feedback, I'll be fixing this soon, if you found something else please let us know. 😉 |
This is getting complex: mafintosh/is-my-json-valid#172 I'm trying to understand this properly, using this validator: https://json-schema-validator.herokuapp.com/
It depends on how validators treat this: https://runkit.com/pateketrueke/5b9ef02f3cede20011d5f06f The results are weird, seriously!
We'll try to generate an appropriate value for I think rounding up Any thoughts?
|
* Lock deps * Run npm audit fix * Remove old deps; cleanup * Fix package; remove types from sources * Delete old typescript sources; cleanup * Move to modern testing and libs; cleanup * Remove ancient build scripts and lib; cleanup * Upgrade ESLint rules * Fixed schema tests; cleanup * Fixed scripts for CI * Watch more extensions; cleanup * Apply changes from PR #432 * Fix #458 * Add test for #455 * Make ESLint happier; take 1 * Make ESLint happier; take 2 * Add is-my-json-valid to validators * Use Object.assign() instead; fix * Add tests for #456; cleanup * Add ajv to validators; remove jayschema * Fix #453; handle single-prop cases * Add fixedProbabilities option to handle random vs fixed cases; fix #443 * Add tests for #446; cleanup * Ignore properties.default; fix #442 * Add tests for #425; fixed * Add tests for #427; fixed * Fill up with patternProperties; fix #416 * Add support for built-in templates; fix #419 * Add tests for #408; wont fix * Merge references into schemas; fix #345 * Fill missing properties with required ones; fix #369 * Support for seeding on tests; add #379 tests * Improve enum support for other types; fix #405 * Query and pick for random items; fix #400 #429 * Enable resolveJsonPath by default; fix #407 * Add methods for clearing out containers; fix #440 * Remove deref from dependencies; fixing refs issues * Fix resolve order; await on tests * Cleanup * Add tests for #386; pending * Add deprecation logs; cleanup * Exclude external deps to get ~27KB dist, bundle is ~413KB; fix * Call .resolve() on tests; fix * Fix built filenames; cleanup * Revert "Enable resolveJsonPath by default; fix #407" This reverts commit 48b67ab. * Fix exported name as JSONSchemaFaker * Add missing useExamplesValue() from #441; fix * 0.5.0-rc16 * Fix tests on CI * Use Object.assign() instead; fix * Make tests run without async/await; fix * Apply fixedProbabilities on arrays; fix #456 * Increase timeout on CI * Not used anymore * Cleanup; WIP * Moving and updating docs; WIP * Improve docs * Enable ignoreMissingRefs flag support; fix * Typo * Force typecasted type fo fix #467 * Fix bullets * Build dist files * Fixed tests * Test for custom typecasting; fix * Run all tests; fix
Hello,I just found another problem when multipleOf is float
It was expected to be a number between 7 and 10, just like 7.01, or 9.99 Then I found the source code: https://github.com/json-schema-faker/json-schema-faker/blob/master/src/lib/types/number.js line38 to line50, in line50, should And in this ut, https://github.com/json-schema-faker/json-schema-faker/blob/master/tests/schema/core/issues/issue-252.json Thank you very much for your replying. |
Interesting issue, feel free to change the code as you think and submit it as PR! I'll be checking this as soon as I can, any help is very appreciated. |
Hi, was the original issue resolved? I just ran a schema through the online .org site and it didn't generate fake values that were faithful to my multipleOf definitions. Thanks, |
Hi @GaryStrange I think it is solved, but you know, there could be regressions. ¿Can you share the schema and output you got? Thank you! |
It appears to be non-deterministic so if you have enough 'number' attributes you can increase your chances of exposing the problem. enter... { into https://json-schema-faker.js.org/ and you should see at least on fake with more than 7 d.p |
Woah, you're using |
Hi, I am experiencing the same problem as @GaryStrange with the multipleOf definitions. Currently working with SAP data types, and you can see a snippet of my schema below: Using jsf.generate() on the schema I am then returned this: Here you can see 'CDEC31_0' does not conform to the multipleOf = 1. Hope this makes sense, and that you can help :) |
Got it, I think we could spent some time rewriting a simple solution for multipleOf, then integrate it back to JS, what do you think? |
Hi, I just started to play with your library and noticed one thing:
What I expect here is two decimal places at most. I can imagine that you might be aware of that as this project looks mature, but I couldn't find any issue related to that.
The text was updated successfully, but these errors were encountered: