mail_validation 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 011cff547dd9e860de9cc3f545e89842e5fcb4a9
|
4
|
+
data.tar.gz: a3a39f1f37bd7908911752cc09ce8a9479937ee6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60e323e4ce6bddba0f3d697633df2bea0eafa1cd95e7a686d0315fb1766bc5c717556ab71e9311c53fbc389a93f6a340675597144711e045a1930e1052da4125
|
7
|
+
data.tar.gz: 877530775c201f0ddbf5b4abe8d2cf162c9a8716764ebe4c496522e73c9386c0f8e856594de751f1a8fc4e07e66089d772effab2af9de1ef480c9f10d65f9caf
|
@@ -5,7 +5,7 @@ module MailValidation
|
|
5
5
|
def validate_each(record, attribute, value)
|
6
6
|
begin
|
7
7
|
address = Mail::Address.new(value)
|
8
|
-
if address.domain.nil?
|
8
|
+
if address.domain.nil? || !address.domain.match(/\.[A-Za-z]+\z/)
|
9
9
|
append_error(record, attribute)
|
10
10
|
end
|
11
11
|
rescue Mail::Field::ParseError => e
|
@@ -22,6 +22,14 @@ describe MailValidation::EmailValidator do
|
|
22
22
|
expect(user).to_not be_valid
|
23
23
|
end
|
24
24
|
|
25
|
+
it 'adds an error if the email does not have a TLD' do
|
26
|
+
user = User.new.tap do |u|
|
27
|
+
u.email = 'bademail@example'
|
28
|
+
end
|
29
|
+
|
30
|
+
expect(user).to_not be_valid
|
31
|
+
end
|
32
|
+
|
25
33
|
it 'adds an error if the email is invalid' do
|
26
34
|
user = User.new.tap do |u|
|
27
35
|
u.email = '@.com'
|