diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index bc24714af..94cb92f0e 100755 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -1463,8 +1463,8 @@ class ApiController(RedditController, OAuth2ResourceController): type = VOneOf('type', ('public', 'private', 'restricted', 'archived')), link_type = VOneOf('link_type', ('any', 'link', 'self')), wikimode = VOneOf('wikimode', ('disabled', 'modonly', 'anyone')), - wiki_edit_karma = VInt("wiki_edit_karma", coerce=False, min=0), - wiki_edit_age = VInt("wiki_edit_age", coerce=False, min=0), + wiki_edit_karma = VInt("wiki_edit_karma", coerce=False, num_default=0, min=0), + wiki_edit_age = VInt("wiki_edit_age", coerce=False, num_default=0, min=0), ip = ValidIP(), sponsor_text =VLength('sponsorship-text', max_length = 500), sponsor_name =VLength('sponsorship-name', max_length = 64), diff --git a/r2/r2/controllers/validator/validator.py b/r2/r2/controllers/validator/validator.py index 7dba2b343..0d20fc7fa 100644 --- a/r2/r2/controllers/validator/validator.py +++ b/r2/r2/controllers/validator/validator.py @@ -1157,11 +1157,13 @@ class VBoolean(Validator): class VNumber(Validator): def __init__(self, param, min=None, max=None, coerce = True, - error = errors.BAD_NUMBER, *a, **kw): + error=errors.BAD_NUMBER, num_default=None, + *a, **kw): self.min = self.cast(min) if min is not None else None self.max = self.cast(max) if max is not None else None self.coerce = coerce self.error = error + self.num_default = num_default Validator.__init__(self, param, *a, **kw) def cast(self, val): @@ -1169,7 +1171,7 @@ class VNumber(Validator): def run(self, val): if not val: - return + return self.num_default try: val = self.cast(val) if self.min is not None and val < self.min: