Created
February 14, 2012 00:02
-
-
Save insin/1821617 to your computer and use it in GitHub Desktop.
Formatting horrible if
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run_validators(self, value): | |
if value in validators.EMPTY_VALUES: | |
return | |
errors = [] | |
for v in self.validators: | |
try: | |
v(value) | |
except ValidationError, e: | |
message = None | |
if hasattr(e, 'code') and e.code in self.error_messages: | |
error_message = self.error_messages[e.code] | |
default = self.default_error_messages.get(e.code, None) | |
if not default or error_message != default: | |
message = error_message | |
if e.params: | |
message = message % e.params | |
if message: | |
errors.append(message) | |
else: | |
errors.extend(e.messages) | |
if errors: | |
raise ValidationError(errors) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment