Faker generating strange phone numbers?

dluxcru picture dluxcru · May 31, 2017 · Viewed 13.1k times · Source

So I'm creating a database with Laravel and seeding it, and I ran into an issue where it generates a phone number as follows: (635) 889-5802 x45134. This causes issues by exceeding the desired length of the database column.

So my questions are:

  1. On a practical level, why does it do this? What is the real-world use case of x#####? I'm looking around and can't find a good explanation, best guess is an internal organization extension.
  2. When building an application where internationalization might eventually be important, is it a good idea to build in support for whatever these are? If so, then expanding the column width would be a better solution for me.
  3. If this isn't important, is there a way to prevent these x##### from being attached to the number on generation? I feel like this should be an option. If not it sounds like my best options would be a custom provider or a regex filter to remove these values.

Answer

Michael Mior picture Michael Mior · May 31, 2017

x#### is commonly used to indicate a phone extension. From looking at the source code for the phone number provider, there's no option to remove the extension so you'd have to do so yourself.

However, you may want to consider reading Falsehoods Programmers Believe About Phone Numbers.