Skip to content

Commit

Permalink
Add model name validation for double spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mcttn22 committed Mar 18, 2024
1 parent 2a0b07f commit 7b46c9d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions school_project/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,25 @@ def manage_testing(self, test_thread: threading.Thread) -> None:
def save_model(self) -> None:
"""Save the model, save the model information to the database, then
enter the home frame."""
model_name = self.save_model_name_entry.get()
model_name = self.save_model_name_entry.get().strip()

# Check if model name is empty
if model_name == '':
if len(model_name) == 0:
self.test_frame.model_status_label.configure(
text="Model name can not be blank",
fg='red'
)
return

# Check if model contains double spaces or greater
elif ' ' in model_name:
self.test_frame.model_status_label.configure(
text="Only single spaces are allowed",
fg='red'
)
return


# Check if model name has already been taken
dataset = self.dataset_option_menu_var.get().replace(" ", "_")
sql = """
Expand Down

0 comments on commit 7b46c9d

Please sign in to comment.