From: Thierry Parmentelat Date: Fri, 9 Jul 2010 16:48:09 +0000 (+0200) Subject: check boolean input (entering "True" would mean false...) X-Git-Tag: myplc-5.0-8~1 X-Git-Url: http://git.onelab.eu/?p=myplc.git;a=commitdiff_plain;h=0a2734bcebbfe41d7a3397929d8b190a47d1e2bd check boolean input (entering "True" would mean false...) --- diff --git a/plc_config.py b/plc_config.py index fcab1f6..b82fb57 100644 --- a/plc_config.py +++ b/plc_config.py @@ -840,9 +840,16 @@ DO NOT EDIT. This file was automatically generated at return True except: return False + def email_validator(val): + return re.match('\A[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9._\-]+\.[a-zA-Z]+\Z', val) + + def boolean_validator (val): + return val in ['true', 'false'] + validators = { - 'email' : lambda val: re.match('\A[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9._\-]+\.[a-zA-Z]+\Z', val), - 'ip': ip_validator + 'email' : email_validator, + 'ip': ip_validator, + 'boolean': boolean_validator, } # validate it if not a know type.