add basic validation support

This commit is contained in:
Martin
2016-06-30 15:45:20 +02:00
parent 7dcb8c5f50
commit 39188e6000
4 changed files with 40 additions and 2 deletions
+14
View File
@@ -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