floere / phony

E164 international phone number normalizing, splitting, formatting.
http://florianhanke.com/phony/
MIT License
1.01k stars 226 forks source link

Croatia too restrictive #379

Closed pzupan closed 2 years ago

pzupan commented 7 years ago

I have a user trying to enter his croation telephone number +385 98 352 085 and it is being rejected.

floere commented 7 years ago

Which version is this about?

On Monday, 5 June 2017, Paul Zupan notifications@github.com wrote:

I have a user trying to enter his croation telephone number +385 98 352 085 and it is being rejected.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/floere/phony/issues/379, or mute the thread https://github.com/notifications/unsubscribe-auth/AAALznWSJ2w2s7adT-pF0sdOlKoluLzjks5sA4s7gaJpZM4NvpL4 .

pzupan commented 7 years ago

Sorry. 2.15.43

floere commented 7 years ago

Could you try 2.15.45 and report back, please?

On Monday, 5 June 2017, Paul Zupan notifications@github.com wrote:

Sorry. 2.15.43

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/floere/phony/issues/379#issuecomment-306219441, or mute the thread https://github.com/notifications/unsubscribe-auth/AAALztvYhlNqg681ug3GyAxC1SNPvAgrks5sBB9-gaJpZM4NvpL4 .

pzupan commented 7 years ago

Still getting the error with 2.15.45.
{:phone=>[{:error=>:improbable_phone}]}

floere commented 7 years ago

@saner @ronin Can you help with this issue? :) (Croatia just got an update via https://github.com/floere/phony/pull/375, however this issue existed pre-update as well)

pzupan commented 7 years ago

Hold on. I'm doing some further testing. This could be an issue with phony_rails...

ronin commented 7 years ago

@pzupan @floere @saner I've checked this number on version 2.15.45 (sha fd09a14ced90dde1316b988b5001a78665632559) and it is accepted.

main:0> Phony.normalize "+385 98 352 085"
=> "38598352085"
main:0> Phony.plausible? "+385 98 352 085"
=> true
pzupan commented 7 years ago

Phony.plausible? "+385 98 352 085" is failing in phony_rails as the local splitter is looking for a length of 7 and the remainder after the national splitter is 6.

# lib/phony/local_splitters/fixed.rb 50
def plausible? rest, hints = {}
     @length === rest.inject(0) { |total, part| total + part.size }
end

I haven't tracked down how the splitter is working yet, but I think the template in croatia.rb is: match(/^(9\d)/) >> split(3, 3..4) | # Mobile Should this result in a @length of 6?