bchavez / Bogus

:card_index: A simple fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.
Other
8.66k stars 495 forks source link

"1-707-975-3864 x110" is not a valid phone number #393

Closed RwSgxx closed 2 years ago

RwSgxx commented 2 years ago

Version Information

Software Version(s)
Bogus NuGet Package 33.1.1
.NET Core? .Net5
.NET Full Framework?
Windows OS? 10 UpToDate
Linux OS?
Visual Studio? 2019 -> 16.11.3

What locale are you using with Bogus?

default

What is the expected behavior?

Generate normal phone numbers that are also parsable by google phone lib.

What is the actual behavior?

It generates phone numbers like: "1-707-975-3864 x110". I've never seen a number like that, and is not parsable by google phone lib.

Please provide a stack trace.


Any possible solutions?

How do you reproduce the issue?

Everything default Ask for a phone number.

Do you have a unit test that can demonstrate the bug?

no

Can you identify the location in Bogus' source code where the problem exists?

no

If the bug is confirmed, would you be willing to submit a PR?

no

Yes or No?

bchavez commented 2 years ago

Hello, the format is a phone number with an extension.

https://github.com/bchavez/Bogus/blob/1406a8ba7ae326dca106bbf5bb827fcd7e47be82/Source/Bogus/data/en.locale.json#L7687-L7698

If you don't want phone numbers with an extension, use the .PhoneNumberFormat(_) method with the appropriate format you'd like. Eg. Index 1 is this format:

https://github.com/bchavez/Bogus/blob/1406a8ba7ae326dca106bbf5bb827fcd7e47be82/Source/Bogus/data/en.locale.json#L7680

   var f = new Faker();
   f.Phone.PhoneNumberFormat(1)
          .Dump();
(250) 824-1596

Or specify your own:

f.Phone.PhoneNumber("###.!##.####").Dump();
865.390.9546

Thanks, Brian