Skip to content

Email (downcase) Parser #127

@inveterateliterate

Description

@inveterateliterate

Feature Description

Suggested Solution

I have been foiled too many times by forgetting to downcase emails prior to saving or when comparing on find. Thoughts on adding an email or downcase parser that downcases, and could also do some other fun email regex?

the regex bit may be a bit much, although there are examples here as well as a lengthy discussion on the pros and cons / challenges:

https://stackoverflow.com/questions/38611405/email-validation-in-ruby-on-rails

Curious if people have solved this in other ways!

Alternatives Considered / Existing Workarounds

  • custom parser, other model code to support, html email input for type validation

Additional Context

In other apps I do have code like:

validates :email, presence: true, uniqueness: { case_sensitive: false } on models with email fields

as well as this:

def self.find_for_authentication(email)
    find_by('lower(email) = ?', email.try(:downcase))
  end

since we did have some mismatch of cases at one time

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions