validators 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/validators/tld.rb +2 -2
- data/lib/validators/version.rb +1 -1
- data/test/validators/validates_email_format_of_test.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 414477d8902b0d37dc91199fe230b37e37131a33bcfec8e61ea8b187f6d30532
|
4
|
+
data.tar.gz: '084b6d7df7b47f7753790955ab5d403d6c7d1584f808ce65e29c8a9da976d875'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f6dedd7eb97652ea82ebb4ba3cab3ea089b8219c3e158dd93e3ff57316fb7e42053a5db72cfdbce3d0d5bd897b431b7348ba4438240d636c3b013bfb00a4ddc
|
7
|
+
data.tar.gz: aea4115b4b68b0d2870f194eba56a8b92b17aaa62a35e86ea2e9e9d1748850d90dc6064b461dad7f2f3be2e5786baff6a54bed6385de8d6cb1a2f0b682977afa
|
data/lib/validators/tld.rb
CHANGED
@@ -9,9 +9,9 @@ module Validators
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.host_with_valid_tld?(host)
|
12
|
-
return false if host.split(".").size == 1
|
12
|
+
return false if host.to_s.split(".").size == 1
|
13
13
|
|
14
|
-
valid?
|
14
|
+
valid?(host[/\.([^.]+)$/, 1].to_s.downcase)
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.valid?(tld)
|
data/lib/validators/version.rb
CHANGED
@@ -82,4 +82,16 @@ class ValidatesEmailFormatOfTest < Minitest::Test
|
|
82
82
|
refute user.valid?
|
83
83
|
assert_includes user.errors[:email], "does not have a valid hostname"
|
84
84
|
end
|
85
|
+
|
86
|
+
test "rejects nil emails" do
|
87
|
+
user = Buyer.new(email: nil)
|
88
|
+
|
89
|
+
refute user.valid?
|
90
|
+
end
|
91
|
+
|
92
|
+
test "rejects nil emails when validating tld" do
|
93
|
+
user = EmailWithTLD.new(email: nil)
|
94
|
+
|
95
|
+
refute user.valid?
|
96
|
+
end
|
85
97
|
end
|