PyInquirer
PyInquirer copied to clipboard
Custom validator with class attribute
Hello, I'm trying to write a custom validator using a class. The problem is that I need to compare the value in the validate() method with an attribute of the class. I tried with this: `class MyValidator(Validator): def init(self, limit): self.limit = limit Validator.init(self)
def validate(self, number): if number > limit: return "Error!" else: return True`
The problem is that validate() method seems to be never called with this approach. If I remove the constructor from MyValidator, it works but I don't have the "limit" attribute. Is there a solution for this? Thank you
Hmnnn. This seems like you want to be able to pass extra args to the validator???