common_validators 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0636e8954956dd555d02f51f19635b2837a8eb37
|
4
|
+
data.tar.gz: 76d1469d5b1fd38aa4a41cd54901da7871e25165
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2efed94056579becd591685b04de708414585507165422ef7c7720b60d3f1b40bf0e87fa190cd281f61bf581cc965e55194f814c4742e87757a1cb186c46a7b7
|
7
|
+
data.tar.gz: e9e4cefad3b2617d1e39ea4c070a199648152d15a8333505ad12825ea5ab12c2645d2a5c6bd52713d738c03dae5e82281ced8c4c109acc9908f743c4de01373c
|
data/Guardfile
CHANGED
@@ -5,6 +5,6 @@ guard :minitest do
|
|
5
5
|
watch(%r{^test/.+_test\.rb$})
|
6
6
|
watch('test/test_helper.rb') { "test" }
|
7
7
|
|
8
|
-
watch(%r{^app/models/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
9
|
-
watch(%r{^app/validators/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
8
|
+
watch(%r{^app/models/(.+)\.rb$}) { |m| "test/models/#{m[1]}_test.rb" }
|
9
|
+
watch(%r{^app/validators/(.+)\.rb$}) { |m| "test/models/#{m[1]}_test.rb" }
|
10
10
|
end
|
@@ -9,7 +9,12 @@
|
|
9
9
|
# validates :email, email_format: true # optional
|
10
10
|
# validates :email, email_format: true, presence: true # required
|
11
11
|
class EmailFormatValidator < ActiveModel::EachValidator
|
12
|
-
|
12
|
+
# Local part is basically a-z 0-9 and common symbols
|
13
|
+
# http://en.wikipedia.org/wiki/E-mail_address#Local_part
|
14
|
+
#
|
15
|
+
# Domain part is basically any unicode character while the TLD is still
|
16
|
+
# restricted to at least two characters in range of a-z
|
17
|
+
EMAIL_REGEX = /\A(([a-zA-Z0-9+_!#$%&'*+~=\/\{\}\|\`\^\?\-\.]+)@((?:[^(),:;<>@\[\\\]\s\.]+\.)+[a-z]{2,}))?\z/i
|
13
18
|
|
14
19
|
def validate_each(record, attr_name, value)
|
15
20
|
return if value.blank?
|
@@ -43,11 +43,18 @@ class EmailFormatValidatorTest < ActiveSupport::TestCase
|
|
43
43
|
assert_invalid_email "a[lice@example.com"
|
44
44
|
assert_invalid_email "a\\lice@example.com"
|
45
45
|
assert_invalid_email "a]lice@example.com"
|
46
|
+
|
47
|
+
# this causes Ruby email library to crash
|
48
|
+
assert_invalid_email "momodk1é@hotmail.fr"
|
46
49
|
end
|
47
50
|
|
48
51
|
test "valid email" do
|
49
52
|
assert_valid_email ""
|
50
53
|
assert_valid_email "alice@example.com"
|
54
|
+
assert_valid_email "alice+spam@example.com"
|
51
55
|
assert_valid_email "alice@example.com"
|
56
|
+
assert_valid_email "ALICE_123@example.com"
|
57
|
+
assert_valid_email "ann.other@example.com"
|
58
|
+
assert_valid_email "hei@やる.ca"
|
52
59
|
end
|
53
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: common_validators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerry Shaw
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|