Skip to content

Commit 82e6f73

Browse files
authored
fix validating email in strict mode (#976)
To enable strict mode in email validation, mode: :strict should be used, not strict_mode: true.
1 parent 3ab1852 commit 82e6f73

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/clearance/user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ module Validations
150150

151151
included do
152152
validates :email,
153-
email: { strict_mode: true },
153+
email: { mode: :strict },
154154
presence: true,
155155
uniqueness: { allow_blank: true, case_sensitive: true },
156156
unless: :email_optional?

spec/models/user_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
it { is_expected.to have_db_index(:remember_token) }
66
it { is_expected.to validate_presence_of(:email) }
77
it { is_expected.to validate_presence_of(:password) }
8-
it { is_expected.to allow_value("foo;@example.com").for(:email) }
9-
it { is_expected.to allow_value("[email protected]").for(:email) }
10-
it { is_expected.to allow_value("[email protected]").for(:email) }
118
it { is_expected.to allow_value("[email protected]").for(:email) }
129
it { is_expected.to allow_value("[email protected]").for(:email) }
1310
it { is_expected.to allow_value("[email protected]").for(:email) }
1411
it { is_expected.not_to allow_value("example.com").for(:email) }
1512
it { is_expected.not_to allow_value("foo").for(:email) }
1613
it { is_expected.not_to allow_value("foo@").for(:email) }
14+
it { is_expected.not_to allow_value("foo@bar").for(:email) }
1715

1816
describe "#email" do
1917
it "stores email in down case and removes whitespace" do

0 commit comments

Comments
 (0)