This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/util/validation.py

24 lines
661 B
Python
Raw Normal View History

import re
INVALID_PASSWORD_MESSAGE = 'Invalid password, password must be at least ' + \
'8 characters and contain no whitespace.'
def validate_email(email_address):
if re.match(r'[^@]+@[^@]+\.[^@]+', email_address):
return True
return False
def validate_username(username):
# Minimum length of 2, maximum length of 255, no url unsafe characters
return (re.search(r'[^a-z0-9_]', username) is None and
len(username) >= 4 and
len(username) <= 30)
2013-09-28 00:03:07 +00:00
def validate_password(password):
# No whitespace and minimum length of 8
if re.search(r'\s', password):
return False
return len(password) > 7