Merge pull request #6267 from tchak/format-phone-number
format phone numbers
This commit is contained in:
commit
139385bde3
2 changed files with 5 additions and 1 deletions
|
@ -24,4 +24,8 @@ class Champs::PhoneChamp < Champs::TextChamp
|
|||
allow_blank: true,
|
||||
message: I18n.t(:not_a_phone, scope: 'activerecord.errors.messages')
|
||||
}, unless: -> { Phonelib.valid_for_country?(value, :pf) }
|
||||
|
||||
def to_s
|
||||
value.present? ? Phonelib.parse(value).full_national : ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -328,7 +328,7 @@ describe Champ do
|
|||
|
||||
context 'for phone champ' do
|
||||
let(:type_de_champ) { build(:type_de_champ_phone) }
|
||||
let(:value) { "0606060606" }
|
||||
let(:value) { "06 06 06 06 06" }
|
||||
|
||||
it { is_expected.to eq([value]) }
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue