Merge pull request #1527 from leonelcamara/authapi2

Auth refactor
This commit is contained in:
mdipierro
2017-05-01 09:13:18 -05:00
committed by GitHub
6 changed files with 1451 additions and 814 deletions
+14 -3
View File
@@ -2494,9 +2494,14 @@ class IS_LOWER(Validator):
('\\xc3\\xb1', None)
"""
def __call__(self, value):
return (to_bytes(to_unicode(value).lower()), None)
cast_back = lambda x: x
if isinstance(value, str):
cast_back = to_native
elif isinstance(value, bytes):
cast_back = to_bytes
value = to_unicode(value).lower()
return (cast_back(value), None)
class IS_UPPER(Validator):
@@ -2511,7 +2516,13 @@ class IS_UPPER(Validator):
"""
def __call__(self, value):
return (to_bytes(to_unicode(value).upper()), None)
cast_back = lambda x: x
if isinstance(value, str):
cast_back = to_native
elif isinstance(value, bytes):
cast_back = to_bytes
value = to_unicode(value).upper()
return (cast_back(value), None)
def urlify(s, maxlen=80, keep_underscores=False):