Giter Site home page Giter Site logo

Comments (8)

darrenterhune avatar darrenterhune commented on August 27, 2024

@haxney all you need to do here is set Faker::Config.locale to 'en-us' and add in valid us phone number formats to that i18n locale file as it's not yet implemented ;)

from faker.

toobulkeh avatar toobulkeh commented on August 27, 2024

👍 for a Phony/Faker crossover.

from faker.

chellberg avatar chellberg commented on August 27, 2024

For anyone running into this issue today, you just need Faker::Config.locale = 'en-US' (capitalization matters) - implemented in https://github.com/stympy/faker/blob/master/lib/locales/en-US.yml

from faker.

nofxx avatar nofxx commented on August 27, 2024

What I did in an application with heavy phone use was Phony validation, as @toobulkeh mentioned.
Just drop those who fail.

from faker.

dorianmariecom avatar dorianmariecom commented on August 27, 2024

I did:

    phone_number do
      begin
        phone_number = Faker::PhoneNumber.phone_number_with_country_code
        phonelib = Phonelib.parse(phone_number)
      end until phonelib.valid? && phonelib.possible?
      phone_number
    end

from faker.

riffraff avatar riffraff commented on August 27, 2024

for those hitting this issue, I still see it with the en-US locale and recent versions of phonelib

>> Faker::Config.locale = 'en-US'
=> "en-US"
>> 100.times.map { Phonelib.valid? Faker::PhoneNumber.phone_number_with_country_code }.tally
=> {true=>48, false=>52}

the issue seems to be related to extension numbers, as faker will generate stuff with a literal "x" in it, like +1 210.732.4169 x4399.

You can tell phonelib to accept these, and then it should work

>> Phonelib.extension_separate_symbols = %w(ext x # ;)
=> ["ext", "x", "#", ";"]
>> 100.times.map { Phonelib.valid? Faker::PhoneNumber.phone_number_with_country_code }.tally
=> {true=>100}

from faker.

dorianmariecom avatar dorianmariecom commented on August 27, 2024

Are those numbers even valid? I will open an issue on phonelib

from faker.

dorianmariecom avatar dorianmariecom commented on August 27, 2024
>> Phonelib.extension_separate_symbols = %w(ext x # ;)
=> ["ext", "x", "#", ";"]
>> 100.times.map { Phonelib.valid? Faker::PhoneNumber.phone_number_with_country_code }.tall
y
=> {false=>97, true=>3}

from faker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.