def validate(self, response): validated_value = Var.validate(self, response) if not self.constraint(validated_value): constraints = ("\n=====Constraints:\nFor application name: should be lowercase.\n" "For class name: its lowercase version should match the app name, not " "counting underscores (that is, they can be 'foo' and 'F_O_o')") raise ValidateError('Response "%s" did not match constraint. %s' % (response, constraints)) return validated_value
def validate(self, response): validated_value = Var.validate(self, response) if not self.constraint(validated_value): constraints = ( "\n=====Constraints:\nFor application name: should be lowercase.\n" "For class name: its lowercase version should match the app name, not " "counting underscores (that is, they can be 'foo' and 'F_O_o')" ) raise ValidateError('Response "%s" did not match constraint. %s' % (response, constraints)) return validated_value
def __init__(self, name, *, constraint, **kwargs): Var.__init__(self, name, **kwargs) self.constraint = constraint