mirror of
https://github.com/esphome/esphome.git
synced 2026-05-31 07:57:40 +08:00
[config] Provide path for has_at_most_one_of messages (#12277)
This commit is contained in:
@@ -740,9 +740,10 @@ def has_at_most_one_key(*keys):
|
|||||||
if not isinstance(obj, dict):
|
if not isinstance(obj, dict):
|
||||||
raise Invalid("expected dictionary")
|
raise Invalid("expected dictionary")
|
||||||
|
|
||||||
number = sum(k in keys for k in obj)
|
used = set(obj) & set(keys)
|
||||||
if number > 1:
|
if len(used) > 1:
|
||||||
raise Invalid(f"Cannot specify more than one of {', '.join(keys)}.")
|
msg = "Cannot specify more than one of '" + "', '".join(used) + "'."
|
||||||
|
raise MultipleInvalid([Invalid(msg, path=[k]) for k in used])
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
return validate
|
return validate
|
||||||
|
|||||||
Reference in New Issue
Block a user