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

[Feat] Detect zero padded numbers as string #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

heshan0131
Copy link
Collaborator

  • Zero padded numbers as string
  • Zero itself is an integar

@heshan0131 heshan0131 requested a review from nrabinowitz May 23, 2023 21:05
@@ -26,11 +26,15 @@ var RegexList = {
isNumber: /^(\+|\-)?\$?[\d,]*\.?\d+((e|E)(\+|\-)\d+)?%?$/,

// accepts: 12, +123, -12,234
isInt: /^(\+|\-)?[\d,]+$/,
// no accept: 01, 001
isInt: /^(?!0)(\+|\-)?[\d,]+$/,
Copy link
Collaborator Author

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

@@ -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') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (intRegexCheck(value) || value == '0') {
if (intRegexCheck(value) || value === '0') {

Do we know that value is a string? If not, should we also check for value === 0?

@@ -77,8 +77,12 @@ function isFloat(value) {
VALIDATOR_MAP[DATA_TYPES.FLOAT] = isFloat;

// 1, 2.2, 3.456789e+0
const zeroPaddedNumCheck = Utils.buildRegexCheck('isZeroPaddedNumber');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Comment above should now move down?
Nit 2: It looks like this just avoid number parsing - should we explicitly output string in this case, rather than having it fall through the number check?

Copy link
Collaborator Author

@heshan0131 heshan0131 May 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, but that's not how computeColMeta currently designed. with the current implementation
type = allValidators.find(buildValidatorFinder(data, columnName)); The only way to have it return string is to return falsy on the number check, because string is at the bottom of the validator queue

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.

2 participants