示例#1
0
 def validation(object):
     value = object.get(name, None)
     if value == None: return True
     if len(value) < size: return True
     raise exceptions.ValidationInternalError(
         name, "must be smaller than %d characters" % size
     )
示例#2
0
 def validation(object):
     first_value = object.get(first_name, None)
     second_value = object.get(second_name, None)
     if first_value == None: return True
     if second_value == None: return True
     if first_value == second_value: return True
     raise exceptions.ValidationInternalError(
         first_name, "value is not equals to %s" % second_name
     )
示例#3
0
 def validation(object):
     _id = object.get("_id", None)
     value = object.get(name, None)
     if value == None: return True
     db = mongodb.get_db()
     _collection = db[collection]
     item = _collection.find_one({name : value})
     if not item: return True
     if str(item["_id"]) == _id: return True
     raise exceptions.ValidationInternalError(name, "value is duplicate")
示例#4
0
 def validation(object):
     value = object.get(name, None)
     if value == None: return True
     if URL_REGEX.match(value): return True
     raise exceptions.ValidationInternalError(name, "value is not a valid url")
示例#5
0
 def validation(object):
     value = object.get(name, None)
     if value == None: return True
     if value in values: return True
     raise exceptions.ValidationInternalError(name, "value is not in set")
示例#6
0
 def validation(object):
     value = object.get(name, None)
     if value == None: return True
     if len(value): return True
     raise exceptions.ValidationInternalError(name, "value is empty")