You are viewing a single thread.
View all comments View context
0 points
*

By the way, please don’t write regex to try to validate email addresses. Seriously.

Amen.

There are libraries for that; some of them are even good.

Spoiler alert: Few of them are good, and those few are so simple that you might as well not use a library.

The only way to correctly validate an email address is to send a message to it, and verify that it arrived.

permalink
report
parent
reply
0 points

You can use a regex to do basic validation. That regex is .+@.+. Anything beyond that is a waste of time.

permalink
report
parent
reply
0 points

There are also cases where you want to have a disallow list of known bad email providers. That’s also part of the parsing and validating.

permalink
report
parent
reply
0 points

It’s a valid need, but a domain blacklist isn’t part of email parsing and if you conflate the two inside your program then you’re mixing concerns.

Why is the domain blacklist even in your program? It should be a user configurable file or a list of domains in the database.

permalink
report
parent
reply
0 points

That rejects valid emails

permalink
report
parent
reply
0 points

Which ones? In RFC 5322 every address contains an addr-spec at some point, which in turn must include an @. RFC 6854 does not seem to change this. Or did I misread something?

permalink
report
parent
reply

Programming

!programming@programming.dev

Create post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Community stats

  • 3.4K

    Monthly active users

  • 754

    Posts

  • 5.9K

    Comments