Skip to content

Conversation

ST-DDT
Copy link
Member

@ST-DDT ST-DDT commented Mar 1, 2025

Currently, faker.number.float({ min: 6, max: 6, multipleOf: 5 }) does not throw, even though 6 is not a multiple of 5.

This PR removes the shortcut when min === max bypassing the multipleOf checks.
Now, it throws an error similar to int() (and soon bigInt()).


This issue was discovered while reviewing #3402

@ST-DDT ST-DDT added c: bug Something isn't working p: 1-normal Nothing urgent m: number Something is referring to the number module labels Mar 1, 2025
@ST-DDT ST-DDT added this to the vAnytime milestone Mar 1, 2025
@ST-DDT ST-DDT requested review from a team March 1, 2025 01:06
@ST-DDT ST-DDT self-assigned this Mar 1, 2025
Copy link

netlify bot commented Mar 1, 2025

Deploy Preview for fakerjs ready!

Name Link
🔨 Latest commit c1f6552
🔍 Latest deploy log https://app.netlify.com/sites/fakerjs/deploys/67f95335d68e610008efcdbb
😎 Deploy Preview https://deploy-preview-3417.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Mar 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.97%. Comparing base (f70a6f7) to head (c1f6552).
Report is 1 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3417   +/-   ##
=======================================
  Coverage   99.97%   99.97%           
=======================================
  Files        2836     2836           
  Lines      218603   218600    -3     
  Branches      953      951    -2     
=======================================
- Hits       218548   218545    -3     
  Misses         55       55           
Files with missing lines Coverage Δ
src/modules/number/index.ts 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@xDivisionByZerox
Copy link
Member

I'm unsure how to continue here. By semantic versioning definition this change should be considered breaking. On the other side this feature is implemented for at least one year and the issue with this misaligned behaviour was never raised.

@matthewmayer
Copy link
Contributor

It's a bugfix and I think the old behavior is unexpected and undocumented so I think patch-level is ok.

@xDivisionByZerox
Copy link
Member

It's a bugfix and I think the old behavior is unexpected and undocumented so I think patch-level is ok.

Thanks for giving your thought on that. The problem is that semantic versioning doesn't care about a behavior being unexpected. But I partially agree, so I'll approve as well.

@xDivisionByZerox xDivisionByZerox changed the title fix(number): don't ignore float multipleOf when min=max fix(number): don't ignore multipleOf in float when min=max Apr 11, 2025
@xDivisionByZerox xDivisionByZerox merged commit e4cc4e5 into next Apr 11, 2025
23 checks passed
@xDivisionByZerox xDivisionByZerox deleted the fix/number/float/multipleOf-where-min-equals-max branch April 11, 2025 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working m: number Something is referring to the number module p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants