Fix validate required arguments (#25)

This commit is contained in:
Pascal Vizeli 2017-04-30 19:03:26 +02:00 committed by GitHub
parent a61311e928
commit 2e168d089c

View File

@ -72,6 +72,10 @@ def validate_options(raw_schema):
def _single_validate(typ, value):
"""Validate a single element."""
try:
# if required argument
if value is None:
raise vol.Invalid("A required argument is not set!")
if typ == V_STR:
return str(value)
elif typ == V_INT:
@ -86,7 +90,7 @@ def _single_validate(typ, value):
return vol.Url()(value)
raise vol.Invalid("Fatal error for {}.".format(value))
except TypeError:
except ValueError:
raise vol.Invalid(
"Type {} error for {}.".format(typ, value)) from None