add basic validation support
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
# coding=UTF-8
|
||||
|
||||
class ValidationError(Exception):
|
||||
|
||||
def __init__(self, message):
|
||||
Exception.__init__(self)
|
||||
self.message = message
|
||||
|
||||
|
||||
def validate_keys_exists(obj, *keys):
|
||||
for key in keys:
|
||||
if not key in obj:
|
||||
raise ValidationError('No {} is specified'.format(key))
|
||||
return True
|
||||
Reference in New Issue
Block a user