Commit 7742c462 authored by Jelte Jansen's avatar Jelte Jansen

empty list evaluates to False, so check for None explicitely


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/jelte-configuration@826 e5f2f494-b856-4b98-b285-d166d9295462
parent ffe26df9
......@@ -65,7 +65,6 @@ class DataDefinition:
if errors:
errors.append("The is no config_data for this specification")
return False
errors = []
return _validate_spec_list(data_def['config_data'], full, data, errors)
......@@ -207,27 +206,27 @@ def _validate_type(spec, value, errors):
specification"""
data_type = spec['item_type']
if data_type == "integer" and type(value) != int:
if errors:
if errors != None:
errors.append(str(value) + " should be an integer")
return False
elif data_type == "real" and type(value) != float:
if errors:
if errors != None:
errors.append(str(value) + " should be a real")
return False
elif data_type == "boolean" and type(value) != bool:
if errors:
if errors != None:
errors.append(str(value) + " should be a boolean")
return False
elif data_type == "string" and type(value) != str:
if errors:
if errors != None:
errors.append(str(value) + " should be a string")
return False
elif data_type == "list" and type(value) != list:
if errors:
if errors != None:
errors.append(str(value) + " should be a list, not a " + str(value.__class__.__name__))
return False
elif data_type == "map" and type(value) != dict:
if errors:
if errors != None:
errors.append(str(value) + " should be a map")
return False
else:
......@@ -256,7 +255,7 @@ def _validate_spec(spec, full, data, errors):
if item_name in data:
return _validate_item(spec, data[item_name], errors)
elif full and not item_optional:
if errors:
if errors != None:
errors.append("non-optional item " + item_name + " missing")
return False
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment