We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When extending the Vlad class, validators defined as class attributes will keep state from a previous validation around:
Vlad
class YourFirstValidator(Vlad): validators = { 'Column A': [ UniqueValidator() ], 'Column B': [ SetValidator(['Vampire', 'Not A Vampire']) ] }
>>> vlad = YourFirstValidator(source=LocalFile('vladiate/examples/vampires.csv')) >>> vlad.validate() Validating YourFirstValidator(source=LocalFile('vladiate/examples/vampires.csv')) Passed! :) >>> vlad2 = YourFirstValidator(source=LocalFile('vladiate/examples/vampires.csv')) >>> vlad2.validate() Validating YourFirstValidator(source=LocalFile('vladiate/examples/vampires.csv')) Failed :( UniqueValidator failed 3 time(s) (100.0%) on field: 'Column A' Invalid fields: ['('Count Chocula',)', '('Dracula',)', '('Vlad the Impaler',)']
For now, this can be worked around by making validators an instance variable:
validators
class YourSecondValidator(Vlad): def __init__(self, *args, **kwargs): self.validators = { 'Column A': [ UniqueValidator() ], 'Column B': [ SetValidator(['Vampire', 'Not A Vampire']) ] } super(YourSecondValidator, self).__init__(*args, **kwargs)
>>> vlad = YourSecondValidator(source=LocalFile('vladiate/examples/vampires.csv')) >>> vlad.validate() Validating YourSecondValidator(source=LocalFile('vladiate/examples/vampires.csv')) Passed! :) >>> vlad2 = YourSecondValidator(source=LocalFile('vladiate/examples/vampires.csv')) >>> vlad2.validate() Validating YourSecondValidator(source=LocalFile('vladiate/examples/vampires.csv')) Passed! :)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When extending the
Vlad
class, validators defined as class attributes will keep state from a previous validation around:For now, this can be worked around by making
validators
an instance variable:The text was updated successfully, but these errors were encountered: