Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/phony/countries/brazil.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@

service = %w[100 128 190 191 192 193 194 197 198 199] # State specific numbers were not added. See http://www.brasil.gov.br/navegue_por/aplicativos/agenda

special_numbers_3_4 = %w[0800]
toll_free = %w[800 0800]
special_numbers_4 = %w[3003 4003 4004 4020]

Phony.define do
country '55',
match(/^#{ndcs}9\d{8}$/) >> split(5, 4) |
match(/^#{ndcs}[2-5]\d{7}$/) >> split(4, 4) |
one_of(special_numbers_3_4) >> split(3, 4) |
one_of(toll_free) >> split(3, 4) |
one_of(special_numbers_4) >> split(4) |
one_of(service) >> split(3) |
fixed(3) >> split(3)
Expand Down
5 changes: 5 additions & 0 deletions qed/plausibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ NDC with several subscriber number length.
'+267 8 1234 567'
]

#### Brazil

plausible? true: '+55 0800 123 4567'
plausible? true: '+55 800 123 4567'

#### Brunei

plausible? true: '+673 5 523 876'
Expand Down
4 changes: 3 additions & 1 deletion spec/functional/plausibility_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ def self.it_is_correct_for(country_name, options = {})
'+387 60 3456789',
'+387 64 4123456',
'+387 67 1234567']
it 'is correct for Brasil' do
it 'is correct for Brazil' do
expect(Phony).to be_plausible('+55 67 998280912')
expect(Phony).not_to be_plausible('+55 67 98280912')
expect(Phony).not_to be_plausible('+55 11 12345678')
expect(Phony).not_to be_plausible('+55 11 123456789')
expect(Phony).not_to be_plausible('+55 11 023456789')
expect(Phony).to be_plausible('+55 11 22345678')
expect(Phony).to be_plausible('+55 0800 123 4567')
expect(Phony).to be_plausible('+55 800 123 4567')
end

it 'is correct for Bulgaria' do
Expand Down
1 change: 1 addition & 0 deletions spec/lib/phony/countries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def self.it_splits(number, expected)

context 'with special numbers' do
it_splits '5508002221234', %w[55 0800 222 1234]
it_splits '558002221234', %w[55 800 222 1234]
it_splits '5530032221', %w[55 3003 2221]
it_splits '5540209999', %w[55 4020 9999]
it_splits '5540038999', %w[55 4003 8999]
Expand Down