valid_email 0.0.8 → 0.0.9

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: c4456e6c2847371b010454617b3f74f87570bbcd
4
- data.tar.gz: d75f3182b16f5c2f7494bdb1b676a9ceab8fc861
3
+ metadata.gz: dfc486fd0dfb112acae3207a3d736b5209daedb8
4
+ data.tar.gz: c4e004a30caf02049223de8ae0f0bbf8eec8e2ac
5
5
  SHA512:
6
- metadata.gz: 055db62d9c82b22cd0f62544672e982b2d319ff5be0b95e69db6f32018d56322d35bca05d6db068c62c1d6d5edae7d3558e451c3f2e97c7911f4b03e35f4b5a6
7
- data.tar.gz: e7f916e652702635a7730eea9dbc2fdafaf1384d8af203ada7420d76990cf106e70bc595c1f988b5e32771f63f76eac1c869ac9fcd4146bf801a499e6d9e5697
6
+ metadata.gz: 1f819b01ba5a32c6dbf8b076f3a4adc8ba7113d7ad2ebef9844ceaaa52386afa7b767894e37216771b04b16e5c6c8cc1cf1a2d8c0f3bade63f340de3bb8161b7
7
+ data.tar.gz: fcb080bf8c42242267320265e878680c3dac036d3bd5364f9629cbb16b8a93ba1488c98ee2f4d3ffbd8b5593a2bf5d167fc411ac706e1e863b4e41ba685401f4
data/README.md CHANGED
@@ -85,6 +85,10 @@ nil.email? # => false
85
85
  "john@gmail.com".email? # => May return true if it exists. It accepts a hash of options like ValidateEmail.valid?
86
86
  ```
87
87
 
88
+ ## Code Status
89
+
90
+ * [![Build Status](https://travis-ci.org/hallelujah/valid_email.svg?branch=master)](https://travis-ci.org/hallelujah/valid_email)
91
+
88
92
  # Credits
89
93
 
90
94
  * Ramihajamalala Hery hery[at]rails-royce.org
@@ -0,0 +1,5 @@
1
+ sv:
2
+ valid_email:
3
+ validations:
4
+ email:
5
+ invalid: "är ogiltig"
@@ -4,26 +4,22 @@ require 'mail'
4
4
  require 'valid_email/validate_email'
5
5
  class EmailValidator < ActiveModel::EachValidator
6
6
  def validate_each(record,attribute,value)
7
- begin
8
- return if options[:allow_nil] && value.nil?
9
- return if options[:allow_blank] && value.blank?
7
+ return if options[:allow_nil] && value.nil?
8
+ return if options[:allow_blank] && value.blank?
10
9
 
11
- r = ValidateEmail.valid?(value)
12
- # Check if domain has DNS MX record
13
- if r && options[:mx]
14
- require 'valid_email/mx_validator'
15
- r &&= MxValidator.new(:attributes => attributes).validate(record)
16
- elsif r && options[:mx_with_fallback]
17
- require 'valid_email/mx_with_fallback_validator'
18
- r &&= MxWithFallbackValidator.new(:attributes => attributes).validate(record)
19
- end
20
- # Check if domain is disposable
21
- if r && options[:ban_disposable_email]
22
- require 'valid_email/ban_disposable_email_validator'
23
- r &&= BanDisposableEmailValidator.new(:attributes => attributes).validate(record)
24
- end
25
- rescue Exception => e
26
- r = false
10
+ r = ValidateEmail.valid?(value)
11
+ # Check if domain has DNS MX record
12
+ if r && options[:mx]
13
+ require 'valid_email/mx_validator'
14
+ r &&= MxValidator.new(:attributes => attributes).validate(record)
15
+ elsif r && options[:mx_with_fallback]
16
+ require 'valid_email/mx_with_fallback_validator'
17
+ r &&= MxWithFallbackValidator.new(:attributes => attributes).validate(record)
18
+ end
19
+ # Check if domain is disposable
20
+ if r && options[:ban_disposable_email]
21
+ require 'valid_email/ban_disposable_email_validator'
22
+ r &&= BanDisposableEmailValidator.new(:attributes => attributes).validate(record)
27
23
  end
28
24
  record.errors.add attribute, (options[:message] || I18n.t(:invalid, :scope => "valid_email.validations.email")) unless r
29
25
  end
@@ -9,19 +9,20 @@ class ValidateEmail
9
9
  m = Mail::Address.new(value)
10
10
  # We must check that value contains a domain and that value is an email address
11
11
  r = m.domain && m.address == value
12
+ if r
13
+ # Check that domain consists of dot-atom-text elements > 1
14
+ # In mail 2.6.1, domains are invalid per rfc2822 are parsed when they shouldn't
15
+ # This is to make sure we cover those cases
16
+ domain_dot_elements = m.domain.split(/\./)
17
+ r &&= domain_dot_elements.none?(&:blank?) && domain_dot_elements.size > 1
12
18
 
13
- # Check that domain consists of dot-atom-text elements > 1
14
- # In mail 2.6.1, domains are invalid per rfc2822 are parsed when they shouldn't
15
- # This is to make sure we cover those cases
16
- domain_dot_elements = m.domain.split(/\./)
17
- r &&= domain_dot_elements.none?(&:blank?) && domain_dot_elements.size > 1
18
-
19
- # Check if domain has DNS MX record
20
- if r && options[:mx]
21
- require 'valid_email/mx_validator'
22
- r &&= mx_valid?(email)
19
+ # Check if domain has DNS MX record
20
+ if r && options[:mx]
21
+ require 'valid_email/mx_validator'
22
+ r &&= mx_valid?(email)
23
+ end
23
24
  end
24
- rescue Exception => e
25
+ rescue Mail::Field::ParseError
25
26
  r = false
26
27
  end
27
28
  r
@@ -39,7 +40,7 @@ class ValidateEmail
39
40
  end
40
41
  r = mx.size > 0
41
42
  end
42
- rescue Exception =>e
43
+ rescue Mail::Field::ParseError
43
44
  r = false
44
45
  end
45
46
  r
@@ -54,13 +55,13 @@ class ValidateEmail
54
55
  begin
55
56
  m = Mail::Address.new(value)
56
57
  r = !BanDisposableEmailValidator.config.include?(m.domain) if m.domain
57
- rescue Exception => e
58
+ rescue Mail::Field::ParseError
58
59
  r = false
59
60
  end
60
-
61
+
61
62
  r
62
63
  end
63
64
 
64
65
  end
65
66
 
66
- end
67
+ end
@@ -1 +1 @@
1
- ValidEmailVersion = "0.0.8"
1
+ ValidEmailVersion = "0.0.9"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valid_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramihajamalala Hery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-05 00:00:00.000000000 Z
11
+ date: 2014-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -86,6 +86,7 @@ files:
86
86
  - config/locales/fr.yml
87
87
  - config/locales/pl.yml
88
88
  - config/locales/ru.yml
89
+ - config/locales/sv.yml
89
90
  - config/valid_email.yml
90
91
  - lib/valid_email.rb
91
92
  - lib/valid_email/all.rb