mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Add more validation for mysensors (#5493)
* Move isdevice validator under helpers.config_validation. * Check that all persistence files are set and are unique if any is set by user. This is necessary to avoid file name clashes. * Check that a set persistence file has an existing and writable directory. * Check that a device is either a valid device file, "mqtt", or a valid domain name or ip address.
This commit is contained in:
committed by
Paulus Schoutsen
parent
b57f5728c5
commit
a09a772f43
@@ -70,6 +70,15 @@ def boolean(value: Any) -> bool:
|
||||
return bool(value)
|
||||
|
||||
|
||||
def isdevice(value):
|
||||
"""Validate that value is a real device."""
|
||||
try:
|
||||
os.stat(value)
|
||||
return str(value)
|
||||
except OSError:
|
||||
raise vol.Invalid('No device at {} found'.format(value))
|
||||
|
||||
|
||||
def isfile(value: Any) -> str:
|
||||
"""Validate that the value is an existing file."""
|
||||
if value is None:
|
||||
|
||||
Reference in New Issue
Block a user