Class: StandardId::EmailIdentifier

Inherits:
Identifier show all
Defined in:
app/models/standard_id/email_identifier.rb

Constant Summary collapse

LOCAL_PART =

URI::MailTo::EMAIL_REGEXP models the local part as one flat character class that happens to include ., so it accepts dot placements RFC 5322 forbids in an unquoted local part: a leading dot, a trailing dot, and consecutive dots. a..b@example.com passes it.

ESPs do not. Postmark rejects such an address at send time with InvalidEmailRequestError, so a typo accepted at sign-up surfaces much later as a failed delivery job that no operator can act on — the address is already stored and the user is long gone.

Enforce the dot-atom rule instead: the local part is dot-separated atoms, each at least one character. The domain pattern is URI::MailTo's, unchanged.

%r{[A-Za-z0-9!\#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!\#$%&'*+/=?^_`{|}~-]+)*}
DOMAIN =
/[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*/
EMAIL_FORMAT =
/\A#{LOCAL_PART}@#{DOMAIN}\z/

Method Summary

Methods inherited from Identifier

#unverify!, #verified?, #verify!