validates_email_format_of 1.4.6 → 1.4.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,8 @@
2
2
  module ValidatesEmailFormatOf
3
3
  require 'resolv'
4
4
 
5
+ VERSION = '1.4.7'
6
+
5
7
  MessageScope = defined?(ActiveModel) ? :activemodel : :activerecord
6
8
 
7
9
  LocalPartSpecialChars = Regexp.escape('!#$%&\'*-/=?+-^_`{|}~')
@@ -37,7 +39,7 @@ module ValidatesEmailFormatOf
37
39
  }
38
40
  opts = options.merge(default_options) {|key, old, new| old} # merge the default options into the specified options, retaining all specified options
39
41
 
40
- email.strip!
42
+ email.strip! if email
41
43
 
42
44
  # local part max is 64 chars, domain part max is 255 chars
43
45
  # TODO: should this decode escaped entities before counting?
@@ -5,6 +5,15 @@ class Person < ActiveRecord::Base
5
5
  :allow_nil => true
6
6
  end
7
7
 
8
+ class PersonForbidNil < ActiveRecord::Base
9
+ set_table_name 'people'
10
+
11
+ validates_email_format_of :email,
12
+ :on => :create,
13
+ :allow_nil => false
14
+ end
15
+
16
+
8
17
  class MxRecord < ActiveRecord::Base
9
18
  set_table_name 'people'
10
19
 
@@ -151,6 +151,9 @@ class ValidatesEmailFormatOfTest < TEST_CASE
151
151
  def test_should_allow_nil
152
152
  p = create_person(:email => nil)
153
153
  save_passes(p)
154
+
155
+ p = PersonForbidNil.new(:email => nil)
156
+ save_fails(p)
154
157
  end
155
158
 
156
159
  # TODO: find a future-proof way to check DNS records
@@ -158,7 +161,7 @@ class ValidatesEmailFormatOfTest < TEST_CASE
158
161
  pmx = MxRecord.new(:email => 'test@dunae.ca')
159
162
  save_passes(pmx)
160
163
 
161
- pmx = MxRecord.new(:email => 'test@somethingthathasntbeenregistered.com')
164
+ pmx = MxRecord.new(:email => 'test@127.0.0.2')
162
165
  save_fails(pmx)
163
166
  end
164
167
 
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_email_format_of
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 4
9
- - 6
10
- version: 1.4.6
4
+ prerelease:
5
+ version: 1.4.7
11
6
  platform: ruby
12
7
  authors:
13
8
  - Alex Dunae
@@ -15,8 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-05-02 00:00:00 -07:00
19
- default_executable:
13
+ date: 2011-05-13 00:00:00 Z
20
14
  dependencies: []
21
15
 
22
16
  description: Validate e-mail addresses against RFC 2822 and RFC 3696.
@@ -40,7 +34,6 @@ files:
40
34
  - test/validates_email_format_of_test.rb
41
35
  - test/database.yml
42
36
  - test/fixtures/people.yml
43
- has_rdoc: true
44
37
  homepage: https://github.com/alexdunae/validates_email_format_of
45
38
  licenses: []
46
39
 
@@ -55,23 +48,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
48
  requirements:
56
49
  - - ">="
57
50
  - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
51
  version: "0"
62
52
  required_rubygems_version: !ruby/object:Gem::Requirement
63
53
  none: false
64
54
  requirements:
65
55
  - - ">="
66
56
  - !ruby/object:Gem::Version
67
- hash: 3
68
- segments:
69
- - 0
70
57
  version: "0"
71
58
  requirements: []
72
59
 
73
60
  rubyforge_project:
74
- rubygems_version: 1.3.7
61
+ rubygems_version: 1.8.1
75
62
  signing_key:
76
63
  specification_version: 3
77
64
  summary: Validate e-mail addresses against RFC 2822 and RFC 3696.