phonie 3.1.15 → 3.2.0
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 +4 -4
- data/Changelog.md +7 -0
- data/Readme.rdoc +4 -0
- data/lib/phonie/data/phone_countries.yml +1 -1
- data/lib/phonie/railties/locales/en.yml +1 -0
- data/lib/phonie/railties/locales/es.yml +1 -0
- data/lib/phonie/railties/locales/fr.yml +1 -0
- data/lib/phonie/railties/locales/pt-BR.yml +5 -0
- data/lib/phonie/railties/validator.rb +6 -0
- data/lib/phonie/version.rb +1 -1
- data/test/countries/br_test.rb +3 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63430f9a7ddd93501a47912cd0633659a75f4ba4
|
4
|
+
data.tar.gz: 3af1b6b48b273050142341f718831eb025eb572a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a25a8c40fcf39d2f6133863349f61d431bb333ad893627776fd9cf1caf6a9444bb79400059593c5adbc8075428ff8c65d5524ff82f97ffca0bb911f96c1099e
|
7
|
+
data.tar.gz: 9109087504ee399cda986035e77d9504253301b287d73687dc273b164562ff3ff52824bffe4baf419ba3950ca3bbe04d30c4ea6781cf598d42c3c651269d5470
|
data/Changelog.md
CHANGED
data/Readme.rdoc
CHANGED
@@ -90,6 +90,10 @@ Phonie includes an ActiveModel validator. If you are using ActiveModel you can v
|
|
90
90
|
model = SomeModel.new(phone_number: '+1 251 123 4567')
|
91
91
|
model.valid? # true
|
92
92
|
|
93
|
+
Similarly you can validate if a number is a mobile number via:
|
94
|
+
|
95
|
+
validates :mobile_number, mobile_phone: true
|
96
|
+
|
93
97
|
= TODO
|
94
98
|
Add definitions for more countries
|
95
99
|
|
@@ -185,7 +185,7 @@
|
|
185
185
|
:name: Brazil
|
186
186
|
:area_code: ((1[1-9]|2[12478]|3[1-578]|4[1-9]|5[1-5]|6[1-9]|7[134579]|8[1-9]|9[1-9])|0[3589]00)
|
187
187
|
:local_number_format: ([2-5]\d{7}|9?[6-9]\d{7}|\d{7})
|
188
|
-
:mobile_format: ([
|
188
|
+
:mobile_format: (([^4-6]\d9[0-9]{8})|([4-6]\d[7-9][0-9]{7})|((1\d7[0789])|(2[124]7[078])|(3[147]7[78])|((21|7[135]|8[15])78))[0-9]{6})$
|
189
189
|
:number_format: \d{10,11}
|
190
190
|
-
|
191
191
|
:country_code: '253'
|
@@ -5,3 +5,9 @@ class PhoneValidator < ActiveModel::EachValidator
|
|
5
5
|
object.errors.add(attribute, :invalid_phone_number) unless Phonie::Phone.valid?(value)
|
6
6
|
end
|
7
7
|
end
|
8
|
+
|
9
|
+
class MobilePhoneValidator < ActiveModel::EachValidator
|
10
|
+
def validate_each(object, attribute, value)
|
11
|
+
object.errors.add(attribute, :invalid_mobile_phone_number) unless Phonie::Phone.valid?(value) && Phonie::Phone.is_mobile?(value)
|
12
|
+
end
|
13
|
+
end
|
data/lib/phonie/version.rb
CHANGED
data/test/countries/br_test.rb
CHANGED
@@ -55,15 +55,15 @@ class BRTest < Phonie::TestCase
|
|
55
55
|
# Mobile
|
56
56
|
#
|
57
57
|
def test_mobile
|
58
|
-
parse_test('+55 91
|
58
|
+
parse_test('+55 91 97866 5678', '55', "91", '978665678', 'Brazil', true)
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_mobile_low_range
|
62
|
-
parse_test('55
|
62
|
+
parse_test('55 41 7101 4567', '55', '41', '71014567', 'Brazil', true)
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_mobile_high_range
|
66
|
-
parse_test('55 35
|
66
|
+
parse_test('55 35 99910 4567', '55', '35', '999104567', 'Brazil', true)
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_mobile_area_11_with_9
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phonie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomislav Car
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activemodel
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- lib/phonie/railties/locales/en.yml
|
99
99
|
- lib/phonie/railties/locales/es.yml
|
100
100
|
- lib/phonie/railties/locales/fr.yml
|
101
|
+
- lib/phonie/railties/locales/pt-BR.yml
|
101
102
|
- lib/phonie/railties/validator.rb
|
102
103
|
- lib/phonie/version.rb
|
103
104
|
- phonie.gemspec
|