18 lines
473 B
Python
18 lines
473 B
Python
# coding=UTF-8
|
|
from api.models.market import iter_markets
|
|
from api.exceptions import ValidationError
|
|
|
|
|
|
def validate_keys_exists(obj, *keys):
|
|
for key in keys:
|
|
if not key in obj:
|
|
raise ValidationError('No {} is specified'.format(key))
|
|
return True
|
|
|
|
|
|
def validate_territory(value):
|
|
for market in iter_markets():
|
|
if market.territory == value:
|
|
return True
|
|
raise ValidationError('{} is not a valid territory'.format(value))
|