mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 05:24:53 +01:00
Time SNTP validate server format (#254)
This commit is contained in:
parent
f2f869db89
commit
3d49ffa134
2 changed files with 8 additions and 1 deletions
|
@ -9,7 +9,7 @@ SNTPComponent = time_.time_ns.class_('SNTPComponent', time_.RealTimeClockCompone
|
|||
|
||||
PLATFORM_SCHEMA = time_.TIME_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(SNTPComponent),
|
||||
vol.Optional(CONF_SERVERS): vol.All(cv.ensure_list, [cv.string], vol.Length(min=1, max=3)),
|
||||
vol.Optional(CONF_SERVERS): vol.All(cv.ensure_list, [cv.domain], vol.Length(min=1, max=3)),
|
||||
vol.Optional(CONF_LAMBDA): cv.lambda_,
|
||||
}).extend(cv.COMPONENT_SCHEMA.schema)
|
||||
|
||||
|
|
|
@ -441,6 +441,13 @@ def hostname(value):
|
|||
return value
|
||||
|
||||
|
||||
def domain(value):
|
||||
value = string(value)
|
||||
if re.match(vol.DOMAIN_REGEX, value) is None:
|
||||
raise vol.Invalid("Invalid domain: {}".format(value))
|
||||
return value
|
||||
|
||||
|
||||
def domain_name(value):
|
||||
value = string(value)
|
||||
if not value.startswith('.'):
|
||||
|
|
Loading…
Reference in a new issue