Skip to content

Bad email validator #349

@iUnstable0

Description

@iUnstable0

This email validator incorrectly accepts test@ok as a valid input. While it follows the HTML specification for email address validation, the regex provided on that website also matches emails without a top-level domain (TLD), such as test@gmailcom. This is problematic for several reasons:

  1. Public-Facing Applications: For public-facing applications, accepting emails without a TLD can lead to invalid user inputs, causing potential issues with email delivery and user verification processes.

  2. Rare Usage in Development: Even in development environments, it is rare to see local email addresses without a TLD. Most development setups use valid TLDs to simulate real-world scenarios. (if im being honest they js use their personal or burner mail lol)

To address these concerns, I suggest enforcing a stricter validation that requires a TLD. This can be achieved by modifying the regex to ensure the presence of a TLD. Here is an example of a stricter regex:

/^[-a-zA-Z0-9_.]+@[-a-zA-Z0-9]+\.[a-zA-Z]{2,4}$/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions