1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-06 13:22:19 +01:00

Improve config final validation (#1917)

This commit is contained in:
Otto Winter
2021-06-17 21:54:14 +02:00
committed by GitHub
parent c19b3ecd43
commit 2419bc3678
18 changed files with 303 additions and 162 deletions

View File

@@ -75,6 +75,9 @@ Inclusive = vol.Inclusive
ALLOW_EXTRA = vol.ALLOW_EXTRA
UNDEFINED = vol.UNDEFINED
RequiredFieldInvalid = vol.RequiredFieldInvalid
# this sentinel object can be placed in an 'Invalid' path to say
# the rest of the error path is relative to the root config path
ROOT_CONFIG_PATH = object()
RESERVED_IDS = [
# C++ keywords http://en.cppreference.com/w/cpp/keyword
@@ -218,8 +221,8 @@ class Required(vol.Required):
- *not* the `config.get(CONF_<KEY>)` syntax.
"""
def __init__(self, key):
super().__init__(key)
def __init__(self, key, msg=None):
super().__init__(key, msg=msg)
def check_not_templatable(value):
@@ -1073,6 +1076,7 @@ def invalid(message):
def valid(value):
"""A validator that is always valid and returns the value as-is."""
return value