Conversation
heshan0131
commented
May 23, 2023
- Zero padded numbers as string
- Zero itself is an integar
Signed-off-by: Shan He <heshan0131@gmail.com>
| // accepts: 12, +123, -12,234 | ||
| isInt: /^(\+|\-)?[\d,]+$/, | ||
| // no accept: 01, 001 | ||
| isInt: /^(?!0)(\+|\-)?[\d,]+$/, |
There was a problem hiding this comment.
the only senario this doesn't handle is the actual 0
| const intRegexCheck = Utils.buildRegexCheck('isInt'); | ||
| function isInt(value) { | ||
| if (intRegexCheck(value)) { | ||
| if (intRegexCheck(value) || value == '0') { |
There was a problem hiding this comment.
| 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?
| VALIDATOR_MAP[DATA_TYPES.FLOAT] = isFloat; | ||
|
|
||
| // 1, 2.2, 3.456789e+0 | ||
| const zeroPaddedNumCheck = Utils.buildRegexCheck('isZeroPaddedNumber'); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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