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

Handle null/undefined options for isInt and isFloat #2330

Closed
wants to merge 2 commits into from
Closed

Handle null/undefined options for isInt and isFloat #2330

wants to merge 2 commits into from

Conversation

omalk98
Copy link

@omalk98 omalk98 commented Oct 23, 2023

What has been modified

Bug(isInt): Returns true in case an option was passed as null/undefined for that specific condition
Bug(isFloat): Returns true in case an option was passed as null/undefined for that specific condition

What has been done

Added checks for null and undefined in both functions isInt and isFloat to be able to handle cases of null/undefined

Old code example:

isInt("5", {min: undefined, max: null}) // => false
isInt("5", {gt: null, lt: undefined}) // => false

isFloat("5.5", {min: null, max: undefined}) // => false
isFloat("5.5", {gt: undefined, lt: null}) // => false

Updated (New) code example:

isInt("5", {min: undefined, max: null}) // => true
isInt("5", {gt: null, lt: undefined}) // => true

isFloat("5.5", {min: null, max: undefined}) // => true
isFloat("5.5", {gt: undefined, lt: null}) // => true

Issue Referenced

#2328

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)
  • References provided in PR (where applicable)

@codecov
Copy link

codecov bot commented Oct 23, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b958bd7) 99.95% compared to head (c450fe6) 99.95%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2330      +/-   ##
==========================================
- Coverage   99.95%   99.95%   -0.01%     
==========================================
  Files         107      107              
  Lines        2454     2449       -5     
  Branches      619      619              
==========================================
- Hits         2453     2448       -5     
  Partials        1        1              
Files Coverage Δ
src/lib/isFloat.js 100.00% <ø> (ø)
src/lib/isInt.js 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@omalk98 omalk98 closed this by deleting the head repository Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant