|
def validate_input(self): |
|
error = None |
|
if not self.firstname or self.firstname.isspace(): |
|
error = 'Please fill in firstname field!' |
|
elif not self.lastname or self.lastname.isspace(): |
|
error = 'Please fill in lastname field!' |
|
elif not self.othernames or self.othernames.isspace(): |
|
error = 'Please fill in othernames field!' |
|
if not self.username or self.username.isspace(): |
|
error = 'Please fill in username field!' |
|
if not self.isAdmin or self.isAdmin.isspace(): |
|
error = 'Please select user role!' |
|
return error |
|
|
|
def validate_inputs(self): |
|
errors = None |
|
if not self.email or self.email.isspace(): |
|
errors = 'Please fill in email field!' |
|
elif not self.phoneNumber or self.phoneNumber.isspace(): |
|
errors = 'Please fill in phoneNumber field!' |
|
elif not re.match(r"[^@.]+@[A-Za-z]+\.[a-z]+", self.email): |
|
errors = 'Please fill in right email format!.' |
|
elif not self.password or self.password.isspace(): |
|
errors = 'Plese fill in password field!' |
|
elif len(self.password) < 8: |
|
errors = 'Password must be of 8 characters long!' |
|
return errors |