Zeroconf lowercase (#44675)

This commit is contained in:
Paulus Schoutsen
2020-12-31 01:06:26 +01:00
committed by GitHub
parent b290a8b5a1
commit c7bf7b32a2
5 changed files with 48 additions and 20 deletions

View File

@@ -33,6 +33,22 @@ def documentation_url(value: str) -> str:
return value
def verify_lowercase(value: str):
"""Verify a value is lowercase."""
if value.lower() != value:
raise vol.Invalid("Value needs to be lowercase")
return value
def verify_uppercase(value: str):
"""Verify a value is uppercase."""
if value.upper() != value:
raise vol.Invalid("Value needs to be uppercase")
return value
MANIFEST_SCHEMA = vol.Schema(
{
vol.Required("domain"): str,
@@ -45,8 +61,8 @@ MANIFEST_SCHEMA = vol.Schema(
vol.Schema(
{
vol.Required("type"): str,
vol.Optional("macaddress"): str,
vol.Optional("name"): str,
vol.Optional("macaddress"): vol.All(str, verify_uppercase),
vol.Optional("name"): vol.All(str, verify_lowercase),
}
),
)