Add case insensitive testing to boolean string validation.

This commit is contained in:
Jan Harkes 2016-04-04 00:38:58 -04:00 committed by Paulus Schoutsen
parent eb415d7b96
commit cbe9a7d2a3
2 changed files with 16 additions and 0 deletions

View file

@ -23,6 +23,7 @@ longitude = vol.All(vol.Coerce(float), vol.Range(min=-180, max=180),
def boolean(value):
"""Validate and coerce a boolean value."""
if isinstance(value, str):
value = value.lower()
if value in ('1', 'true', 'yes', 'on', 'enable'):
return True
if value in ('0', 'false', 'no', 'off', 'disable'):