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

Using Number.MAX_SAFE_INTEGER throw error that number unsafe. #1637

Closed
paxa1887 opened this issue Nov 6, 2018 · 3 comments
Closed

Using Number.MAX_SAFE_INTEGER throw error that number unsafe. #1637

paxa1887 opened this issue Nov 6, 2018 · 3 comments
Assignees
Labels
bug Bug or defect
Milestone

Comments

@paxa1887
Copy link
Contributor

paxa1887 commented Nov 6, 2018

  • joi version: 14.0

What are you trying to achieve or the steps to reproduce ?

  1. Use Number.MAX_SAFE_INTEGER.
if (isNumber) {
            if (!this._flags.unsafe &&
                (value >= Number.MAX_SAFE_INTEGER || value <= Number.MIN_SAFE_INTEGER)) {
                result.errors = this.createError('number.unsafe', { value }, state, options);
            }
        }

joi/lib/types/number/index.js

Which result you had ?

  1. Obtain error that number unsafe.

What did you expect ?

  1. Expect that value Number.MAX_SAFE_INTEGER is the safe integer.
    Number.isSafeInteger(Number.MAX_SAFE_INTEGER);
    // true
@kanongil
Copy link
Contributor

kanongil commented Nov 6, 2018

Indeed, it seems that the test added in 11afe35 is a bit too restrictive.

@kanongil kanongil added the bug Bug or defect label Nov 6, 2018
Marsup added a commit that referenced this issue Nov 11, 2018
…TEGER_throw_error

fix condition, add tests for safe numbers
@Marsup
Copy link
Collaborator

Marsup commented Nov 11, 2018

Closed by #1638.

@Marsup Marsup closed this as completed Nov 11, 2018
@Marsup Marsup self-assigned this Nov 11, 2018
@Marsup Marsup added this to the 14.0.5 milestone Nov 11, 2018
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug or defect
Projects
None yet
Development

No branches or pull requests

3 participants