Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict on the EmailValidator with another gem (devise_token_auth) #46

Closed
xdmx opened this issue Apr 27, 2016 · 6 comments
Closed

Conflict on the EmailValidator with another gem (devise_token_auth) #46

xdmx opened this issue Apr 27, 2016 · 6 comments

Comments

@xdmx
Copy link

xdmx commented Apr 27, 2016

Steps to reproduce with rails 5:

rails new testemail -B -d postgresql

Add to Gemfile:

gem 'devise_token_auth', github: 'lynndylanhurley/devise_token_auth'
gem 'valid_email2', '~> 1.2.3'

create app/model/invitation.rb

class Invitation
  include ActiveModel::Model

  attr_accessor :email

  validates :email, email: { mx: true, disposable: true }
end
bundle install
git init
heroku create
git add .
git commit -m "init"
git push heroku master
# rails c
x = Invitation.new email: '[email protected]'
x.valid? => false

# heroku run console
x = Invitation.new email: '[email protected]'
x.valid? => true

The problem seems to be that devise_token_auth also has an EmailValidator which overwrites valid_email2's validator.

Is there a way to force to use valid_email2 and not devise_token_auth?

I've tried to change the gemfile with

gem 'valid_email2', '~> 1.2.3'

and adding require 'valid_email2 after Bundler.require(*Rails.groups) in config/application.rb but still loads the wrong one

@micke
Copy link
Owner

micke commented Nov 23, 2016

Sorry, i completely forgot to attend to this issue.

I'm open to move EmailValidator under the ValidEmail2 namespace, this would need to be released as version 2.0.0 as to not break semver. I'm swamped with other stuff right now so a PR is definitely welcomed.

fredngo added a commit to fredngo/valid_email2 that referenced this issue Jul 26, 2017
This is a breaking change. The invocation changes from:

  validates :email, email: true

to

  validates :email, email2: true

This solves micke#46
fredngo added a commit to fredngo/valid_email2 that referenced this issue Jul 26, 2017
This is a breaking change. The invocation changes from:

  validates :email, email: true

to

  validates :email, 'valid_email_2/email': true

This solves micke#46
fredngo added a commit to fredngo/valid_email2 that referenced this issue Jul 26, 2017
This is a breaking change. The invocation changes from:

  validates :email, email: true

to

  validates :email, 'valid_email_2/email': true

This solves micke#46
@fredngo
Copy link
Contributor

fredngo commented Jul 26, 2017

Hello @lisinge! I submit this PR for your consideration: #79

@fredngo
Copy link
Contributor

fredngo commented Aug 2, 2017

Looks like this issue can now be closed :)

@micke
Copy link
Owner

micke commented Aug 2, 2017

I just pushed v2.0.0 to rubygems which includes @fredngo's pr which namespaces the validator.
See https://github.com/lisinge/valid_email2#upgrading-to-v200 for upgrade instructions

@micke micke closed this as completed Aug 2, 2017
@andystu
Copy link

andystu commented Aug 7, 2017

under rails 5 and use devise, I put
=> validates :email, presence: true, 'valid_email_2/email': true
into my user model,
but get error
=> Unknown validator: 'ValidEmail2::EmailValidator'

@micke
Copy link
Owner

micke commented Aug 7, 2017

@andystu Are you sure you are running version 2.0.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants