Allow field attributes which are lists to validate the type of the list items

Starting to apply this for tags too, however it is not correcting things
as would be expected.
This commit is contained in:
James Cammarata 2015-06-27 01:01:08 -04:00
commit bb8d87ceb6
3 changed files with 9 additions and 2 deletions

View file

@ -274,6 +274,10 @@ class Base:
elif attribute.isa == 'list':
if not isinstance(value, list):
value = [ value ]
if attribute.listof is not None:
for item in value:
if not isinstance(item, attribute.listof):
raise AnsibleParserError("the field '%s' should be a list of %s, but the item '%s' is a %s" % (name, attribute.listof, item, type(item)), obj=self.get_ds())
elif attribute.isa == 'dict' and not isinstance(value, dict):
raise TypeError()