Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated phone numbers dont seem to be valid. #1010

Closed
dARKaRK opened this issue Aug 30, 2017 · 1 comment
Closed

Generated phone numbers dont seem to be valid. #1010

dARKaRK opened this issue Aug 30, 2017 · 1 comment

Comments

@dARKaRK
Copy link

dARKaRK commented Aug 30, 2017

I've used Phonelib gem to validate phone number in my models.
When I use Faker::PhoneNumber.phone_number for phone numbers during seed data creation, they don't pass the validation.
One such example is below:

Faker::PhoneNumber.phone_number
 => "1-451-239-5425 x92803"
p = Phonelib.parse "1-451-239-5425 x92803"
 => #<Phonelib::Phone:0x000000135a3b70 @original="1-451-239-5425 x92803", @extension="", @sanitized="1451239542592803", @original_s="1-451-239-5425 x92803", @data={}, @national_number="1451239542592803">
p.valid?
 => false

I guess the whole point of Faker is to generate fake random things but is there any workaround for models with such validation?

@stympy
Copy link
Contributor

stympy commented Aug 30, 2017

You can either set Phonelib.extension_separator or Phonelib.extension_separate_symbols to use the "x" that Faker returns, or you can override the locale in Faker to change how the extension is returned.

@stympy stympy closed this as completed Aug 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants