Skip to content

Conversation

@heshan0131
Copy link
Collaborator

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

Signed-off-by: Shan He <heshan0131@gmail.com>
@heshan0131 heshan0131 requested a review from nrabinowitz May 23, 2023 21:05
// 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

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?

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.

3 participants