email_valid8 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/email_valid8.rb +16 -4
- 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: f85d7576339e78f200584de0d50f69a21be5751dcb86f8e52f82c34339e9cd02
|
4
|
+
data.tar.gz: b905061960b4d839e004544ee804a3fedbc5e5c0ee724a4a68dd75208c987ccc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa80733325f60155cb19fd9879cbce8a4df8d228f5ea0d683352631d9fdf285269a07785d6475702ce8cc784d5fe89c0ce0050be9d1f36af6702a3e49a8250a2
|
7
|
+
data.tar.gz: bcb5d22a58dfd5ac1376357dcc3c63897c25b8e01adb7c7aeda7e0b63b965b43c4d9ba1efc0005fcc185f1136337ee80c84e5eeb97cd2d5913a4deeb8c92830a
|
data/lib/email_valid8.rb
CHANGED
@@ -13,17 +13,29 @@ class EmailAddressValidator < ActiveModel::Validator
|
|
13
13
|
attrs = record.send(field)
|
14
14
|
if multiples
|
15
15
|
attrs.split(',').each do |attr|
|
16
|
-
attr.class == Array ? attr.each { |email|
|
16
|
+
attr.class == Array ? attr.each { |email| email_checker(email, field, record) } : email_checker(attr.strip, field, record)
|
17
17
|
end
|
18
18
|
else
|
19
|
-
|
19
|
+
email_checker(attrs, field, record)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
return if email
|
24
|
+
def email_checker(email, field, record)
|
25
|
+
return if validation_check(email)
|
26
26
|
|
27
27
|
record.errors.add(field, 'is not written in a valid format')
|
28
28
|
end
|
29
|
+
|
30
|
+
def validation_check(email)
|
31
|
+
email =~ URI::MailTo::EMAIL_REGEXP && email !~ /[A-Z]/
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.valid?(email)
|
35
|
+
validation_check(email)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.invalid?(email)
|
39
|
+
!validation_check(email)
|
40
|
+
end
|
29
41
|
end
|