-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat(isFloat) Fix , passing as float #2020
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2020 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 104 104
Lines 2203 2203
Branches 477 477
=========================================
Hits 2203 2203
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@rubiin do I still need to do anything to have this PR merged? |
Waiting for further approvals from @profnandaa |
@@ -5,7 +5,7 @@ export default function isFloat(str, options) { | |||
assertString(str); | |||
options = options || {}; | |||
const float = new RegExp(`^(?:[-+])?(?:[0-9]+)?(?:\\${options.locale ? decimal[options.locale] : '.'}[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const float = new RegExp(`^(?:[-+])?(?:[0-9]+)?(?:\\${options.locale ? decimal[options.locale] : '.'}[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$`); | |
// largely derived from ECMAScript, with optional leading sign and allowing unnecessary leading zeroes | |
// but not underscore separators | |
// https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html#prod-DecimalLiteral | |
const float = new RegExp(`^[-+]?(?:[0-9]+|(?=.[0-9]))(?:\\${options.locale ? decimal[options.locale] : '.'}[0-9]*)?(?:[eE][-+]?[0-9]+)?$`); |
(and if you take this suggestion, then the following if
is unnecessary)
merging in #2164 |
Similar to #752: Only passing
,
as string will result in a positive outcome ofisFloat
. This simply catches the case similar to.
and+
etc.Checklist