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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19708883f59e2d18eec88fe1bb44b4a9a620b616
4
- data.tar.gz: 6ccc7ae8fe964a11c17012f1ce6c8736979b19d9
3
+ metadata.gz: 63430f9a7ddd93501a47912cd0633659a75f4ba4
4
+ data.tar.gz: 3af1b6b48b273050142341f718831eb025eb572a
5
5
  SHA512:
6
- metadata.gz: 4168b71038855057dff97f0f052c6f5e839b86e75cfe167f9554fab455d95993d84ada73575f06be318d4b8a3495019e3f2f1f42a0d45448883e98fc0673cc2b
7
- data.tar.gz: 58c10a2450711ba8b1fc4d730cd3552f5f52b46ef18ee2efb6f358aa9182915cb0d599d5ed77d682dc9f1bdd17a546ba678e20d3827bb7b2a171470637951db3
6
+ metadata.gz: 2a25a8c40fcf39d2f6133863349f61d431bb333ad893627776fd9cf1caf6a9444bb79400059593c5adbc8075428ff8c65d5524ff82f97ffca0bb911f96c1099e
7
+ data.tar.gz: 9109087504ee399cda986035e77d9504253301b287d73687dc273b164562ff3ff52824bffe4baf419ba3950ca3bbe04d30c4ea6781cf598d42c3c651269d5470
@@ -1,3 +1,10 @@
1
+ 3.2.0
2
+ =====
3
+
4
+ * Improves BR mobile detection (Thanks @mfbmina)
5
+ * Adds an new validator for mobile numbers (Thanks @mfbmina)
6
+ * Adds a pt-BR locale for error messages (Thanks @mfbmina)
7
+
1
8
  3.1.15
2
9
  ======
3
10
 
@@ -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: ([129][1-9]9|[3-9][1-9])[6-9]\d{7}
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'
@@ -2,3 +2,4 @@ en:
2
2
  errors:
3
3
  messages:
4
4
  invalid_phone_number: Invalid phone number
5
+ invalid_mobile_phone_number: Invalid mobile phone number
@@ -2,3 +2,4 @@ es:
2
2
  errors:
3
3
  messages:
4
4
  invalid_phone_number: Teléfono inválido
5
+ invalid_mobile_phone_number: Teléfono celular inválido
@@ -2,3 +2,4 @@ fr:
2
2
  errors:
3
3
  messages:
4
4
  invalid_phone_number: Numéro de téléphone invalide
5
+ invalid_mobile_phone_number: Téléphone cellulaire invalide
@@ -0,0 +1,5 @@
1
+ pt-BR:
2
+ errors:
3
+ messages:
4
+ invalid_phone_number: Número de telefone inválido
5
+ invalid_mobile_phone_number: Número de celular inválido
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Phonie
2
- VERSION = '3.1.15'
2
+ VERSION = '3.2.0'
3
3
  end
@@ -55,15 +55,15 @@ class BRTest < Phonie::TestCase
55
55
  # Mobile
56
56
  #
57
57
  def test_mobile
58
- parse_test('+55 91 9786 5678', '55', "91", '97865678', 'Brazil', true)
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 35 6101 4567', '55', '35', '61014567', 'Brazil', true)
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 9991 4567', '55', '35', '99914567', 'Brazil', true)
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.1.15
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: 2015-11-30 00:00:00.000000000 Z
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