def validate(self, response): validated_value = Var.validate(self, response) if not self.constraint(validated_value): raise ValidateError('Response "%s" did not match constraint.' % response) return validated_value
def __init__(self, name, *, constraint, **kwargs): Var.__init__(self, name, **kwargs) self.constraint = constraint