validates_as_email_address 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'rake/contrib/sshpublisher'
|
|
5
5
|
|
6
6
|
spec = Gem::Specification.new do |s|
|
7
7
|
s.name = 'validates_as_email_address'
|
8
|
-
s.version = '0.2.
|
8
|
+
s.version = '0.2.2'
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.summary = 'Adds support for validating the format/length of email addresses'
|
11
11
|
|
@@ -3,6 +3,10 @@ require 'validates_as_email_address/rfc_1035'
|
|
3
3
|
|
4
4
|
# Adds validations for email addresses
|
5
5
|
module ValidatesAsEmailAddress
|
6
|
+
# The default error message to use for improperly formatted e-mail addresses
|
7
|
+
mattr_accessor :invalid_email_message
|
8
|
+
self.invalid_email_message = 'is an invalid email address'
|
9
|
+
|
6
10
|
# Validates whether the value of the specific attribute matches against the
|
7
11
|
# RFC822/RFC1035 specification.
|
8
12
|
#
|
@@ -46,7 +50,7 @@ module ValidatesAsEmailAddress
|
|
46
50
|
def validates_as_email_address(*attr_names)
|
47
51
|
configuration = attr_names.last.is_a?(Hash) ? attr_names.pop : {}
|
48
52
|
configuration.reverse_merge!(
|
49
|
-
:wrong_format => ActiveRecord::Errors.default_error_messages[:invalid_email],
|
53
|
+
:wrong_format => Object.const_defined?(:I18n) ? :invalid_email : ActiveRecord::Errors.default_error_messages[:invalid_email],
|
50
54
|
:strict => true
|
51
55
|
)
|
52
56
|
|
@@ -67,7 +71,12 @@ ActiveRecord::Base.class_eval do
|
|
67
71
|
extend ValidatesAsEmailAddress
|
68
72
|
end
|
69
73
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
)
|
74
|
+
|
75
|
+
# Load default error messages
|
76
|
+
if Object.const_defined?(:I18n) # Rails >= 2.2
|
77
|
+
I18n.load_path << "#{File.dirname(__FILE__)}/validates_as_email_address/locale.rb"
|
78
|
+
else
|
79
|
+
ActiveRecord::Errors.default_error_messages.update(
|
80
|
+
:invalid_email => ValidatesAsEmailAddress.invalid_email_message
|
81
|
+
)
|
82
|
+
end
|
@@ -9,6 +9,7 @@ class ValidatesAsEmailAddressByDefaultTest < Test::Unit::TestCase
|
|
9
9
|
user = new_user(:email => 'a@')
|
10
10
|
assert !user.valid?
|
11
11
|
assert user.errors.invalid?(:email)
|
12
|
+
assert_equal 'is an invalid email address', user.errors.on(:email).first
|
12
13
|
|
13
14
|
user.email = 'a@a'
|
14
15
|
assert user.valid?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_as_email_address
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Pfeifer
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-03-15 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -24,6 +24,7 @@ extra_rdoc_files: []
|
|
24
24
|
files:
|
25
25
|
- lib/validates_as_email_address
|
26
26
|
- lib/validates_as_email_address/rfc_822.rb
|
27
|
+
- lib/validates_as_email_address/locale.rb
|
27
28
|
- lib/validates_as_email_address/rfc_1035.rb
|
28
29
|
- lib/validates_as_email_address.rb
|
29
30
|
- test/factory.rb
|