Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def validate(self, **kw):
- params = dict(username=kw['username'], email=kw['email'])
- if (self.valid_username(kw['username'], params) and
- self.valid_email(kw['email'], params) and
- self.valid_password(kw['password'], kw['verify'], params)):
- return True, params
- else:
- return False, params
- def valid_username(self, username, params):
- if username and re.match(r"^[a-zA-Z0-9_-]{3,20}$", username):
- return True
- else:
- params['error_username'] = "username is wrong"
- def valid_password(self, password, verify, params):
- if password and re.match(r"^.{3,20}$", password):
- if not (password == verify):
- params['error_verify'] = "passwords should be the same"
- return
- return True
- else:
- params['error_password'] = "password is wrong"
- def valid_email(self, email, params):
- if not email or re.match(r'^[\S]+@[\S]+\.[\S]+$', email):
- return True
- else:
- params['error_email'] = "that's not a valid email"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement