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

Number functions can generate values out of bound #1595

Closed
9 of 10 tasks
Shinigami92 opened this issue Nov 24, 2022 · 0 comments · Fixed by #1648
Closed
9 of 10 tasks

Number functions can generate values out of bound #1595

Shinigami92 opened this issue Nov 24, 2022 · 0 comments · Fixed by #1648
Labels
c: bug Something isn't working m: datatype Something is referring to the datatype module m: number Something is referring to the number module needs test More tests are needed p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug

Comments

@Shinigami92
Copy link
Member

Pre-Checks

Describe the bug

When calling following number methods, they can generate values out of bound.

Minimal reproduction code

faker.datatype.number({ min: 2.1, max: 2.9 }) // Should throw error
faker.number.int({ min: 2.1, max: 2.9 }) // Should throw error

faker.datatype.float({ min: 0, max: 1.9, precision: 0.4 }) // Should not generate `2.0`
faker.number.float({ min: 0, max: 1.9, precision: Math.log10(2.5) }) // Should not generate `2.0`

Additional Context

Found while working on #1122

Environment Info

System:
    OS: macOS 13.0.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.65 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.4.0 - ~/.nvm/versions/node/v18.4.0/bin/node
    npm: 8.12.1 - ~/.nvm/versions/node/v18.4.0/bin/npm
  Browsers:
    Chrome: 107.0.5304.110
    Safari: 16.1

Which module system do you use?

  • CJS
  • ESM

Used Package Manager

pnpm

@Shinigami92 Shinigami92 added c: bug Something isn't working s: pending triage Pending Triage labels Nov 24, 2022
@Shinigami92 Shinigami92 added needs test More tests are needed p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug m: datatype Something is referring to the datatype module m: number Something is referring to the number module labels Nov 24, 2022
@Shinigami92 Shinigami92 removed the s: pending triage Pending Triage label Nov 24, 2022
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: datatype Something is referring to the datatype module m: number Something is referring to the number module needs test More tests are needed p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant