Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add input validation for password length #6

Open
gptgit opened this issue Jul 2, 2023 · 0 comments
Open

Add input validation for password length #6

gptgit opened this issue Jul 2, 2023 · 0 comments

Comments

@gptgit
Copy link

gptgit commented Jul 2, 2023

In the Password_Generator_v1.1.0.py file, the current implementation assumes that the user will always input a valid integer for the password length. However, it would be beneficial to add input validation to ensure that the user enters a valid numeric value.

Steps to Implement:

  1. Modify the generate_func() function to validate the input for the password length before generating the password.
  2. Check if the input value is a valid integer using a try-except block.
  3. Display an error message if the input is not a valid integer and prompt the user to enter a valid numeric value.

Example:

def generate_func():
    text_menu.delete(1.0, END)
    rangee = entry_box.get()
    
    try:
        rangee = int(rangee)  # Validate input as integer
        if rangee <= 0:
            raise ValueError  # Raise error for non-positive values
        
        # Rest of the code for generating the password
        # ...
        
    except ValueError:
        messagebox.showinfo("Error", "Please enter a valid positive integer for password length!")

Expected Behavior:
If the user enters a non-numeric value or a non-positive integer for the password length, an error message will be displayed, prompting them to enter a valid positive integer.

Benefits:

  • Robustness: Input validation ensures that only valid and meaningful inputs are accepted, preventing unexpected behavior or errors during password generation.
  • User-Friendly: By displaying an error message, users are prompted to correct their input, leading to a more user-friendly experience.
  • Improved Accuracy: Input validation helps avoid potential errors or crashes resulting from invalid input values.

Implementing this proposal will enhance the reliability and user experience of the password generator by incorporating input validation for the password length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant