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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/email_valid8.rb +16 -4
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbc8c6de73dc731e3639ff8acb4fcf4c8fe960938e41e7a9c114ae56923281c7
4
- data.tar.gz: d41c6c04fe54bd661a87da7673599719f37fda9a97dd3daae61a0212937e03a5
3
+ metadata.gz: f85d7576339e78f200584de0d50f69a21be5751dcb86f8e52f82c34339e9cd02
4
+ data.tar.gz: b905061960b4d839e004544ee804a3fedbc5e5c0ee724a4a68dd75208c987ccc
5
5
  SHA512:
6
- metadata.gz: 4f240e8bc9ed9436414e8adef66c002481064d0bf5724c2573ae90c7484a18b42fb3c88c82119c9927e5bd1e70d9ca9d0d30b5dda3e3d1e76ba75bd9b23d5fd9
7
- data.tar.gz: 56fd85bc0dd6f3be8b4bae96a54571b43f3eab5a3e52e42928b9c7ca0a9b89b242c3c037156b1e3bf7316feba942a8575945b72e6214def9ea50ed49a3595c35
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| check_email(email, field, record) } : check_email(attr.strip, field, record)
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
- check_email(attrs, field, record)
19
+ email_checker(attrs, field, record)
20
20
  end
21
21
  end
22
22
  end
23
23
 
24
- def check_email(email, field, record)
25
- return if email =~ URI::MailTo::EMAIL_REGEXP && email !~ /[A-Z]/
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_valid8
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Boyd