mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-13 20:26:29 +00:00
Fix validate required arguments (#25)
This commit is contained in:
parent
a61311e928
commit
2e168d089c
@ -72,6 +72,10 @@ def validate_options(raw_schema):
|
|||||||
def _single_validate(typ, value):
|
def _single_validate(typ, value):
|
||||||
"""Validate a single element."""
|
"""Validate a single element."""
|
||||||
try:
|
try:
|
||||||
|
# if required argument
|
||||||
|
if value is None:
|
||||||
|
raise vol.Invalid("A required argument is not set!")
|
||||||
|
|
||||||
if typ == V_STR:
|
if typ == V_STR:
|
||||||
return str(value)
|
return str(value)
|
||||||
elif typ == V_INT:
|
elif typ == V_INT:
|
||||||
@ -86,7 +90,7 @@ def _single_validate(typ, value):
|
|||||||
return vol.Url()(value)
|
return vol.Url()(value)
|
||||||
|
|
||||||
raise vol.Invalid("Fatal error for {}.".format(value))
|
raise vol.Invalid("Fatal error for {}.".format(value))
|
||||||
except TypeError:
|
except ValueError:
|
||||||
raise vol.Invalid(
|
raise vol.Invalid(
|
||||||
"Type {} error for {}.".format(typ, value)) from None
|
"Type {} error for {}.".format(typ, value)) from None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user