Add async friendly helper for validating config schemas (#123800)

* Add async friendly helper for validating config schemas

* Improve docstrings

* Add tests
This commit is contained in:
Erik Montnemery
2024-08-17 11:01:49 +02:00
committed by GitHub
parent a7bca9bcea
commit 533442f33e
4 changed files with 161 additions and 7 deletions

View File

@@ -1535,7 +1535,9 @@ async def async_process_component_config(
# No custom config validator, proceed with schema validation
if hasattr(component, "CONFIG_SCHEMA"):
try:
return IntegrationConfigInfo(component.CONFIG_SCHEMA(config), [])
return IntegrationConfigInfo(
await cv.async_validate(hass, component.CONFIG_SCHEMA, config), []
)
except vol.Invalid as exc:
exc_info = ConfigExceptionInfo(
exc,
@@ -1570,7 +1572,9 @@ async def async_process_component_config(
# Validate component specific platform schema
platform_path = f"{p_name}.{domain}"
try:
p_validated = component_platform_schema(p_config)
p_validated = await cv.async_validate(
hass, component_platform_schema, p_config
)
except vol.Invalid as exc:
exc_info = ConfigExceptionInfo(
exc,