1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-13 23:33:48 +01:00

[core] Add make_name_with_suffix helper to optimize string concatenation

This commit is contained in:
J. Nick Koston
2025-10-11 10:51:17 -10:00
parent dcf2697a2a
commit 6273380407
9 changed files with 47 additions and 8 deletions

View File

@@ -1195,6 +1195,13 @@ def validate_bytes(value):
def hostname(value):
"""Validate that the value is a valid hostname.
Maximum length is 63 characters per RFC 1035.
Note: If this limit is changed, update MAX_NAME_WITH_SUFFIX_SIZE in
esphome/core/application.h to accommodate the new maximum length.
"""
value = string(value)
if re.match(r"^[a-z0-9-]{1,63}$", value, re.IGNORECASE) is not None:
return value