mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-03 23:14:02 -07:00
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:
parent
f68223b9ed
commit
bb8d87ceb6
3 changed files with 9 additions and 2 deletions
|
@ -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()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue