From e130549e82a3d59af46f2d595ed47fa9a39724a3 Mon Sep 17 00:00:00 2001 From: Matt Mayer <152770+matthewmayer@users.noreply.github.com> Date: Tue, 12 Mar 2024 18:01:00 +0700 Subject: feat(phone)!: add new style parameter (#2578) --- docs/guide/upgrading_v9/2578.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 docs/guide/upgrading_v9/2578.md (limited to 'docs/guide') diff --git a/docs/guide/upgrading_v9/2578.md b/docs/guide/upgrading_v9/2578.md new file mode 100644 index 00000000..cb2963d2 --- /dev/null +++ b/docs/guide/upgrading_v9/2578.md @@ -0,0 +1,15 @@ +### faker.phone.number `style` replaces explicit `format` + +`faker.phone.number()` generates a phone number for the current locale. However, previously there was little control over the generated number, which might or might not include country codes, extensions, white space and punctuation. + +If you wanted more control over the number, it was previously necessary to pass an explicit `format` parameter. This has now been removed. Instead, you can consider one of two options: + +1. The new `style` parameter has convenient options for common use cases. There are three possible values. + +- - `'human'`: (default, existing behavior) A human-input phone number, e.g. `555-770-7727` or `555.770.7727 x1234` +- - `'national'`: A phone number in a standardized national format, e.g. `(555) 123-4567`. +- - `'international'`: A phone number in a E.123 standard international format with country code, e.g. `+15551234567` + +The styles are locale-aware, so for example if you use pt_PT, phone numbers suitable for Portugal would be generated. + +2. If none of the `style`s match your needs, you can use `faker.string.numeric()` or `faker.helpers.fromRegExp()` to create a custom pattern. -- cgit v1.2.3