mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Validate required list items are not None or empty strings
Fixes #12011
This commit is contained in:
parent
6da2587c36
commit
21e421ce53
1 changed files with 3 additions and 0 deletions
|
@ -298,6 +298,9 @@ class Base:
|
||||||
for item in value:
|
for item in value:
|
||||||
if not isinstance(item, attribute.listof):
|
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())
|
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.required and attribute.listof == string_types:
|
||||||
|
if item is None or item.strip() == "":
|
||||||
|
raise AnsibleParserError("the field '%s' is required, and cannot have empty values" % (name,), obj=self.get_ds())
|
||||||
elif attribute.isa == 'set':
|
elif attribute.isa == 'set':
|
||||||
if not isinstance(value, (list, set)):
|
if not isinstance(value, (list, set)):
|
||||||
value = [ value ]
|
value = [ value ]
|
||||||
|
|
Loading…
Reference in a new issue