Spaces:
Runtime error
Runtime error
IsaacKerson
commited on
Commit
•
de912b6
1
Parent(s):
3817395
add error handling for empty inputs
Browse files- pages/join.py +5 -1
- pages/utils.py +3 -0
pages/join.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
from pickle import FALSE
|
|
|
2 |
import streamlit as st
|
3 |
import sqlite3
|
4 |
import datetime
|
@@ -41,7 +42,10 @@ def app():
|
|
41 |
|
42 |
submitted = st.form_submit_button("Submit")
|
43 |
|
44 |
-
if
|
|
|
|
|
|
|
45 |
st.warning("The passwords do not match.")
|
46 |
elif user_name in usernames:
|
47 |
st.warning("This user name already exists.")
|
|
|
1 |
from pickle import FALSE
|
2 |
+
from pages.utils import not_empty
|
3 |
import streamlit as st
|
4 |
import sqlite3
|
5 |
import datetime
|
|
|
42 |
|
43 |
submitted = st.form_submit_button("Submit")
|
44 |
|
45 |
+
if empty(first_name) or empty(last_name) or empty(user_name) \
|
46 |
+
or empty(email) or empty(password1) or empty(password2):
|
47 |
+
st.warning("Complete all inputs.")
|
48 |
+
elif submitted and password1.strip() != password2.strip():
|
49 |
st.warning("The passwords do not match.")
|
50 |
elif user_name in usernames:
|
51 |
st.warning("This user name already exists.")
|
pages/utils.py
CHANGED
@@ -6,6 +6,9 @@ import string
|
|
6 |
import sqlite3
|
7 |
import re
|
8 |
|
|
|
|
|
|
|
9 |
def add_blanks(word, sentence, blank = "__"):
|
10 |
return re.sub(word, blank, sentence, flags=re.IGNORECASE)
|
11 |
|
|
|
6 |
import sqlite3
|
7 |
import re
|
8 |
|
9 |
+
def empty(string):
|
10 |
+
return len(string) == 0
|
11 |
+
|
12 |
def add_blanks(word, sentence, blank = "__"):
|
13 |
return re.sub(word, blank, sentence, flags=re.IGNORECASE)
|
14 |
|