better error message when validating int
This commit is contained in:
parent
6ec8348355
commit
4d8390c1fe
@ -267,12 +267,12 @@ class IntRange(DataType):
|
|||||||
try:
|
try:
|
||||||
fvalue = float(value)
|
fvalue = float(value)
|
||||||
value = int(value)
|
value = int(value)
|
||||||
if not self.min <= value <= self.max or round(fvalue) != fvalue:
|
|
||||||
raise BadValueError('%r should be an int between %d and %d' %
|
|
||||||
(value, self.min, self.max))
|
|
||||||
return value
|
|
||||||
except Exception:
|
except Exception:
|
||||||
raise BadValueError('Can not convert %r to int' % value)
|
raise BadValueError('Can not convert %r to int' % value)
|
||||||
|
if not self.min <= value <= self.max or round(fvalue) != fvalue:
|
||||||
|
raise BadValueError('%r should be an int between %d and %d' %
|
||||||
|
(value, self.min, self.max))
|
||||||
|
return value
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
args = (self.min, self.max)
|
args = (self.min, self.max)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user