aboutsummaryrefslogtreecommitdiff
path: root/docs/guide
diff options
context:
space:
mode:
authorMatt Mayer <[email protected]>2024-03-12 18:01:00 +0700
committerGitHub <[email protected]>2024-03-12 11:01:00 +0000
commite130549e82a3d59af46f2d595ed47fa9a39724a3 (patch)
tree13756af384807ff792a8aa8a4d2c62dda056e613 /docs/guide
parentaade09bf6a10fb22f4ebb163931cf1e98ba9ea28 (diff)
downloadfaker-e130549e82a3d59af46f2d595ed47fa9a39724a3.tar.xz
faker-e130549e82a3d59af46f2d595ed47fa9a39724a3.zip
feat(phone)!: add new style parameter (#2578)
Diffstat (limited to 'docs/guide')
-rw-r--r--docs/guide/upgrading_v9/2578.md15
1 files changed, 15 insertions, 0 deletions
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.