add is_number validator
This commit is contained in:
@@ -10,6 +10,21 @@ def validate_keys_exists(obj, *keys):
|
||||
return True
|
||||
|
||||
|
||||
def is_number(s):
|
||||
try:
|
||||
float(s)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
def validate_number(*values):
|
||||
for val in values:
|
||||
if not is_number(val):
|
||||
raise ValidationError('{} is not a number'.format(val))
|
||||
return True
|
||||
|
||||
|
||||
def validate_territory(value):
|
||||
for market in iter_markets():
|
||||
if market.territory == value:
|
||||
|
||||
Reference in New Issue
Block a user