mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Add support for field descriptions in config flows (#68604)
This commit is contained in:
@@ -110,6 +110,7 @@ def gen_data_entry_schema(
|
||||
step_title_class("title"): cv.string_with_no_html,
|
||||
vol.Optional("description"): cv.string_with_no_html,
|
||||
vol.Optional("data"): {str: cv.string_with_no_html},
|
||||
vol.Optional("data_description"): {str: cv.string_with_no_html},
|
||||
vol.Optional("menu_options"): {str: cv.string_with_no_html},
|
||||
}
|
||||
},
|
||||
@@ -125,7 +126,19 @@ def gen_data_entry_schema(
|
||||
removed_title_validator, config, integration
|
||||
)
|
||||
|
||||
return schema
|
||||
def data_description_validator(value):
|
||||
"""Validate data description."""
|
||||
for step_info in value["step"].values():
|
||||
if "data_description" not in step_info:
|
||||
continue
|
||||
|
||||
for key in step_info["data_description"]:
|
||||
if key not in step_info["data"]:
|
||||
raise vol.Invalid(f"data_description key {key} is not in data")
|
||||
|
||||
return value
|
||||
|
||||
return vol.All(vol.Schema(schema), data_description_validator)
|
||||
|
||||
|
||||
def gen_strings_schema(config: Config, integration: Integration):
|
||||
|
||||
Reference in New Issue
Block a user