Permalink
Browse files

validator: Correct BAD_NUMBER when min or max was None.

  • Loading branch information...
1 parent bc91f31 commit 53e29b26f18f8639fb9e18e494a791f84f2e0bc6 @andre-d committed Sep 21, 2012
Showing with 10 additions and 3 deletions.
  1. +1 −1 r2/r2/controllers/errors.py
  2. +9 −2 r2/r2/controllers/validator/validator.py
@@ -55,7 +55,7 @@
('USER_DOESNT_EXIST', _("that user doesn't exist")),
('NO_USER', _('please enter a username')),
('INVALID_PREF', "that preference isn't valid"),
- ('BAD_NUMBER', _("that number isn't in the right range (%(min)d to %(max)d)")),
+ ('BAD_NUMBER', _("that number isn't in the right range (%(range)s)")),
('BAD_STRING', _("you used a character here that we can't handle")),
('BAD_BID', _("your bid must be at least $%(min)d per day and no more than to $%(max)d in total.")),
('ALREADY_SUB', _("that link has already been submitted")),
@@ -1184,8 +1184,15 @@ def run(self, val):
raise ValueError, ""
return val
except ValueError:
- self.set_error(self.error, msg_params = dict(min=self.min,
- max=self.max))
+ if self.max is None and self.min is None:
+ range = ""
+ elif self.max is None:
+ range = _("%(min)d to any") % dict(min=self.min)
+ elif self.min is None:
+ range = _("any to %(max)d") % dict(max=self.max)
+ else:
+ range = _("%(min)d to %(max)d") % dict(min=self.min, max=self.max)
+ self.set_error(self.error, msg_params=dict(range=range))
class VInt(VNumber):
def cast(self, val):

0 comments on commit 53e29b2

Please sign in to comment.