mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
network/library: don't allow empty string settings for ArgValidatorStr types
In most cases at hand, and empty string value is non-sensical. Flip the default for "allow_empty" to get this validation for all string settings.
This commit is contained in:
parent
a9634a85f1
commit
90853dc7cf
1 changed files with 2 additions and 4 deletions
|
|
@ -427,7 +427,7 @@ class ArgValidator:
|
|||
return result
|
||||
|
||||
class ArgValidatorStr(ArgValidator):
|
||||
def __init__(self, name, required = False, default_value = None, enum_values = None, allow_empty = True):
|
||||
def __init__(self, name, required = False, default_value = None, enum_values = None, allow_empty = False):
|
||||
ArgValidator.__init__(self, name, required, default_value)
|
||||
self.enum_values = enum_values
|
||||
self.allow_empty = allow_empty
|
||||
|
|
@ -591,7 +591,7 @@ class ArgValidator_DictIP(ArgValidatorDict):
|
|||
default_value = list,
|
||||
),
|
||||
ArgValidatorList('dns_search',
|
||||
nested = ArgValidatorStr('dns_search[?]', allow_empty = False),
|
||||
nested = ArgValidatorStr('dns_search[?]'),
|
||||
default_value = list,
|
||||
),
|
||||
],
|
||||
|
|
@ -681,8 +681,6 @@ class ArgValidator_DictConnection(ArgValidatorDict):
|
|||
raise ValidationError(name + '.' + k, 'property is not allowed for state "%s"' % (result['state']))
|
||||
|
||||
if result['state'] != 'wait':
|
||||
if 'name' in result and not result['name']:
|
||||
raise ValidationError(name + '.name', 'empty "name" is invalid')
|
||||
if result['state'] == 'absent':
|
||||
if 'name' not in result:
|
||||
result['name'] = '' # set to empty string to mean *absent all others*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue