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

fix issue #4 request.get_username fetch invalidated username #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

WajahatKanju
Copy link

Pull Request Title

Enhance UserForm Validation and Error Handling

Pull Request Description

This pull request enhances the existing UserForm in the project by improving validation and error handling for the username field. The changes make the form more user-friendly and maintainable. Here's a summary of the improvements:

  1. Field-Specific Validation: Moved username validation to a dedicated clean_username method within the form class. This allows for clearer separation of validation concerns and better organization of code.

  2. Refined Character Validation: Updated the character validation logic to ensure that the username contains only allowed characters (letters, numbers, periods, hyphens, and underscores). The use of isalnum() improves readability and maintainability.

  3. Error Messages: Utilized Django's default error messages for required field validation and invalid characters. This promotes consistency throughout the project and simplifies the error message handling.

  4. Label Definition: Centralized label definition within the Meta class to improve code readability and label management for multiple fields.

  5. Username Composition Validation: Implemented checks to disallow usernames containing '@' or '+', which are common in email addresses and can lead to potential confusion or misuse.

These enhancements not only improve the user experience by providing more informative error messages but also enhance the codebase's maintainability and readability. The changes have been thoroughly tested to ensure they do not introduce regressions. This pull request aims to provide a more robust and user-friendly UserForm for the project.

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

Successfully merging this pull request may close these issues.

1 participant