Skip to content

Conversation

@aditbiswas1
Copy link
Collaborator

No description provided.

@manjitkumar manjitkumar self-assigned this May 8, 2017
INT, LONG
]

class GenericSeperatedValidatorTestCase(unittest.TestCase):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Spelling error: Use Separated everywhere.

GenericSeperatedValidator.validation() should be passed to the schema
>>> CSVofIntegers = GenericSeperatedValidator(int, ',')
>>> CSVofIntegers.validation()('1,2,3')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of naming the method validation, you can override the __call__ method so that this validator complies with the others.

return values
else:
raise ValueError
except ValueError as e:
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use a common except block for ValueError and Invalid

'''

def __init__(self, validation_function, seperator=','):
if type(seperator) != basestring:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use isinstance(separator, basestring). basestring is an abstract superclass of str and unicode so this will return True for all string values.

'''

def __init__(self, validation_function, separator=','):
if isinstance(separator, basestring):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be if not isinstance(separator, basestring). Maybe add a test for this case?

else:
self.value_type = validation_function.__name__

def __call__(self, msg=None):
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can move the msg argument to __init__ and make __call__ a normal function that takes the value (instead of it being an HOF). That way, it'll be completely consistent with the other validators, except that it takes arguments in addition to msg.

@adesor
Copy link
Collaborator

adesor commented May 9, 2017

There are some commits which aren't worded properly or are fix-up commits. When you're done with your changes, please reword your commits wherever you feel you should and squash fix-up commits. You can refer to this for good commit message practices.

@aditbiswas1 aditbiswas1 force-pushed the csv-validator branch 2 times, most recently from d07db3a to c699bdc Compare May 9, 2017 10:36
@aditbiswas1
Copy link
Collaborator Author

updated

@aditbiswas1 aditbiswas1 closed this May 9, 2017
@aditbiswas1 aditbiswas1 reopened this May 9, 2017
@manjitkumar manjitkumar merged commit 3b9ee75 into manjitkumar:master May 9, 2017
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