Corrections for IS_INT_IN_RANGE

This commit is contained in:
Stefan Pochmann
2013-10-12 21:10:29 +02:00
parent c3a7486930
commit 667069b573
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -6925,8 +6925,10 @@ def sqlhtml_validators(field):
requires.append(validators.IS_EMPTY_OR(validators.IS_JSON(native_json=field.db._adapter.native_json)))
elif field_type == 'double' or field_type == 'float':
requires.append(validators.IS_FLOAT_IN_RANGE(-1e100, 1e100))
elif field_type in ('integer','bigint'):
requires.append(validators.IS_INT_IN_RANGE(-2**31, 2**31-1))
elif field_type == 'integer':
requires.append(validators.IS_INT_IN_RANGE(-2**31, 2**31))
elif field_type == 'bigint':
requires.append(validators.IS_INT_IN_RANGE(-2**63, 2**63))
elif field_type.startswith('decimal'):
requires.append(validators.IS_DECIMAL_IN_RANGE(-10**10, 10**10))
elif field_type == 'date':
+1 -1
View File
@@ -743,7 +743,7 @@ class IS_INT_IN_RANGE(Validator):
% dict(min=self.minimum, max=self.maximum - 1)
def __call__(self, value):
if value and regex_isint.match(str(value)):
if value is not None and regex_isint.match(str(value)):
v = int(value)
if ((self.minimum is None or v >= self.minimum) and
(self.maximum is None or v < self.maximum)):