Allow easier customization of whole domain, entity lists, globs. (#5215)
This commit is contained in:
parent
ab19577322
commit
addc2c4340
8 changed files with 285 additions and 48 deletions
|
@ -376,6 +376,8 @@ def ordered_dict(value_validator, key_validator=match_all):
|
|||
"""Validate ordered dict."""
|
||||
config = OrderedDict()
|
||||
|
||||
if not isinstance(value, dict):
|
||||
raise vol.Invalid('Value {} is not a dictionary'.format(value))
|
||||
for key, val in value.items():
|
||||
v_res = item_validator({key: val})
|
||||
config.update(v_res)
|
||||
|
@ -385,6 +387,13 @@ def ordered_dict(value_validator, key_validator=match_all):
|
|||
return validator
|
||||
|
||||
|
||||
def ensure_list_csv(value: Any) -> Sequence:
|
||||
"""Ensure that input is a list or make one from comma-separated string."""
|
||||
if isinstance(value, str):
|
||||
return [member.strip() for member in value.split(',')]
|
||||
return ensure_list(value)
|
||||
|
||||
|
||||
# Validator helpers
|
||||
|
||||
def key_dependency(key, dependency):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue