def testTransformsLambda(self): def my_callable(v): return True validator = Validator.of(my_callable) self.assertIsInstance(validator, LambdaValidator) self.assertTrue(validator.isValid("test"))
def __init__(self, pm: PropertyManager, validators=None): self.pm = pm self.pm.wire(self._fireCallbacks) if validators is None: self.validators = {} else: self.validators = {k: Validator.of(v) for k, v in validators.items()} super().__init__()
def __init__(self, pm: PropertyManager, validators=None): super().__init__(pm) if validators is None: self.validators = {} else: self.validators = { k: Validator.of(v) for k, v in validators.items() }
def testReturnsValidator(self): validator = NumberValidator() self.assertIs(validator, Validator.of(validator))
def testGetsValidatorByKey(self): validator = Validator.of("str") self.assertIsInstance(validator, StringValidator)
def setValidator(self, key, validator): self.validators[key] = Validator.of(validator)