News for hackers. Stuff that matters.
Re:Stop Validating Email Addresses with Regex (2012) by adalu on Wednesday April 20, 2022 @01:43PM (#31100398)

  ```
  //pseudo Go
  import (
    "strings"
    "internal/inputs"
  )
  
  func emailValid(input inputs.ProfileInput) bool {
    if len(input.Email < 3) {
      return false
    }
    return strings.Contains(input.Email, "@")
  }
  ```
An email should be at least 3 chars long and contain a @ sign to be valid.

a@a can be a valid email address if your hostname is a and your mta accepts the email address. A user a may or may not exist (virtual).

And as the author wrote 10 years ago, if the mail doesn't arrive, no validation can help if the email address doesn't exist. But len>=3 and @ sign presence is enough of a sanity check.

Re:Stop Validating Email Addresses with Regex (2012) by leohonexus on Wednesday April 20, 2022 @02:24PM (#31100975)
I like the simplicity, but @@@ isn’t a valid email address (and .@. isn’t too, same as @…---…, and soon enough we’ll quickly regress back to the original problem of having too long of a regex)