fixed problem with IS_INT_IN_RANGE for large numbers

This commit is contained in:
mdipierro
2013-10-11 16:59:05 -05:00
parent 59290534bc
commit d8e8d1d597
3 changed files with 7 additions and 18 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.7.2-stable+timestamp.2013.10.09.11.56.54 Version 2.7.2-stable+timestamp.2013.10.11.16.58.14
+1 -1
View File
@@ -6926,7 +6926,7 @@ def sqlhtml_validators(field):
elif field_type == 'double' or field_type == 'float': elif field_type == 'double' or field_type == 'float':
requires.append(validators.IS_FLOAT_IN_RANGE(-1e100, 1e100)) requires.append(validators.IS_FLOAT_IN_RANGE(-1e100, 1e100))
elif field_type in ('integer','bigint'): elif field_type in ('integer','bigint'):
requires.append(validators.IS_INT_IN_RANGE(-1e100, 1e100)) requires.append(validators.IS_INT_IN_RANGE(-2**31, 2**31-1))
elif field_type.startswith('decimal'): elif field_type.startswith('decimal'):
requires.append(validators.IS_DECIMAL_IN_RANGE(-10**10, 10**10)) requires.append(validators.IS_DECIMAL_IN_RANGE(-10**10, 10**10))
elif field_type == 'date': elif field_type == 'date':
+5 -16
View File
@@ -692,7 +692,7 @@ class IS_INT_IN_RANGE(Validator):
>>> IS_INT_IN_RANGE(1,5)(5) >>> IS_INT_IN_RANGE(1,5)(5)
(5, 'enter an integer between 1 and 4') (5, 'enter an integer between 1 and 4')
>>> IS_INT_IN_RANGE(1,5)(3.5) >>> IS_INT_IN_RANGE(1,5)(3.5)
(3, 'enter an integer between 1 and 4') (3.5, 'enter an integer between 1 and 4')
>>> IS_INT_IN_RANGE(None,5)('4') >>> IS_INT_IN_RANGE(None,5)('4')
(4, None) (4, None)
>>> IS_INT_IN_RANGE(None,5)('6') >>> IS_INT_IN_RANGE(None,5)('6')
@@ -741,24 +741,13 @@ class IS_INT_IN_RANGE(Validator):
% dict(min=self.minimum, max=self.maximum - 1) % dict(min=self.minimum, max=self.maximum - 1)
def __call__(self, value): def __call__(self, value):
try: if value and str(value).isdigit():
fvalue = float(value)
value = int(value) value = int(value)
if value != fvalue: if ((self.minimum is None or value >= self.minimum) and
return (value, self.error_message) (self.maximum is None or value < self.maximum)):
if self.minimum is None: return (value, None)
if self.maximum is None or value < self.maximum:
return (value, None)
elif self.maximum is None:
if value >= self.minimum:
return (value, None)
elif self.minimum <= value < self.maximum:
return (value, None)
except ValueError:
pass
return (value, self.error_message) return (value, self.error_message)
def str2dec(number): def str2dec(number):
s = str(number) s = str(number)
if not '.' in s: if not '.' in s: