Skip to content

Commit

Permalink
Fix email validator strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
hasghari committed Jan 5, 2024
1 parent 630f175 commit bf6233c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/clearance/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ module Validations

included do
validates :email,
email: { strict_mode: true },
email: { mode: :strict },
presence: true,
uniqueness: { allow_blank: true, case_sensitive: true },
unless: :email_optional?
Expand Down
6 changes: 3 additions & 3 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
it { is_expected.to have_db_index(:remember_token) }
it { is_expected.to validate_presence_of(:email) }
it { is_expected.to validate_presence_of(:password) }
it { is_expected.to allow_value("foo;@example.com").for(:email) }
it { is_expected.to allow_value("foo@.example.com").for(:email) }
it { is_expected.to allow_value("foo@example..com").for(:email) }
it { is_expected.to allow_value("foo@example.co.uk").for(:email) }
it { is_expected.to allow_value("foo@example.com").for(:email) }
it { is_expected.to allow_value("foo+bar@example.com").for(:email) }
it { is_expected.not_to allow_value("example.com").for(:email) }
it { is_expected.not_to allow_value("foo").for(:email) }
it { is_expected.not_to allow_value("foo@").for(:email) }
it { is_expected.not_to allow_value("foo;@example.com").for(:email) }
it { is_expected.not_to allow_value("foo@.example.com").for(:email) }
it { is_expected.not_to allow_value("foo@example..com").for(:email) }

describe "#email" do
it "stores email in down case and removes whitespace" do
Expand Down

0 comments on commit bf6233c

Please sign in to comment.