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:
@@ -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
|
||||
|
Reference in New Issue
Block a user