-
Notifications
You must be signed in to change notification settings - Fork 13
[Feat] Detect zero padded numbers as string #36
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -60,7 +60,7 @@ VALIDATOR_MAP[DATA_TYPES.TIME] = Utils.buildRegexCheck('isTime'); | |||||
| // 1, 2, 3, +40, 15,121 | ||||||
| const intRegexCheck = Utils.buildRegexCheck('isInt'); | ||||||
| function isInt(value) { | ||||||
| if (intRegexCheck(value)) { | ||||||
| if (intRegexCheck(value) || value == '0') { | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Do we know that |
||||||
| var asNum = parseInt(value.toString().replace(/(\+|,)/g, ''), 10); | ||||||
| return asNum > Number.MIN_SAFE_INTEGER && asNum < Number.MAX_SAFE_INTEGER; | ||||||
| } | ||||||
|
|
@@ -77,8 +77,12 @@ function isFloat(value) { | |||||
| VALIDATOR_MAP[DATA_TYPES.FLOAT] = isFloat; | ||||||
|
|
||||||
| // 1, 2.2, 3.456789e+0 | ||||||
| const zeroPaddedNumCheck = Utils.buildRegexCheck('isZeroPaddedNumber'); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Comment above should now move down?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea, but that's not how |
||||||
|
|
||||||
| VALIDATOR_MAP[DATA_TYPES.NUMBER] = function isNumeric(row) { | ||||||
| return !isNaN(row) || isInt(row) || isFloat(row); | ||||||
| return ( | ||||||
| (!isNaN(row) && !zeroPaddedNumCheck(row)) || isInt(row) || isFloat(row) | ||||||
| ); | ||||||
| }; | ||||||
|
|
||||||
| // strings: '94101-10', 'San Francisco', 'Name' | ||||||
|
|
||||||
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.
the only senario this doesn't handle is the actual
0