-
-
Notifications
You must be signed in to change notification settings - Fork 933
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
fix(number): bigint shouldn't throw when max is negative #3363
base: next
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for fakerjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
I confirmed that this is a bug in the current version (v9.3.0) of Faker. Adding the acceped label. |
I'm not sure about it.
Vs
Or something similar. If you just need a negative value you could just use |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #3363 +/- ##
==========================================
- Coverage 99.97% 99.97% -0.01%
==========================================
Files 2811 2811
Lines 217023 217028 +5
Branches 942 944 +2
==========================================
+ Hits 216972 216975 +3
- Misses 51 53 +2
|
I agree I think it's fairly intuitive what I don't think it's intuitive what
|
@soc221b Could you please explain your thoughts regarding this change? |
I changed the target branch from |
Thanks for your comments about this.
I personally think giving a negative max is a valid usage even it doesn't seem intuitive.
I'm building a library to generate fake data based on faker.js and ran into this issue: https://github.com/soc221b/zod-schema-faker/blob/1.1.0/src/zod-bigint-faker.ts#L26-L29 I created an example of form validation using |
I've looked at your code and noticed that you also have some code for multipleOf (similar to our |
Sure, I'll create another PR for that. 😃 |
Workaround for -faker.number.bigInt({min: 1}) or with full context: if (min == null && max != null && max < 0) {
return -faker.number.bigInt({ min: -max });
} |
No description provided.