mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-25 06:48:01 -05:00
validator: Correct BAD_NUMBER when min or max was None.
This commit is contained in:
@@ -55,7 +55,7 @@ error_list = dict((
|
||||
('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 @@ class VNumber(Validator):
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user