-
-
Notifications
You must be signed in to change notification settings - Fork 973
feat(phone)!: add new style parameter #2578
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
46e9be7
add support for style
matthewmayer 60f9672
migrate definitions
matthewmayer 8b6ab62
Merge branch 'next' into feat/phone-style
ST-DDT c1671d7
upgrading docs
matthewmayer 11dbd51
add tests
matthewmayer 2bbe9ba
Merge branch 'next' into feat/phone-style
matthewmayer f392ca2
Merge branch 'next' into feat/phone-style
matthewmayer 3544040
update tests
matthewmayer b10f96a
refactor, move to nested format
matthewmayer b83137b
lint
matthewmayer f2ef62b
implement review suggestions
matthewmayer 3b25359
Update index.ts
matthewmayer c296bc0
Update 2578.md
matthewmayer f0dd78e
rename raw to international, add comments in definitions
matthewmayer a47a890
standardize options object code
matthewmayer 6ed77df
change migration guide
matthewmayer 0b32f19
Merge branch 'next' into feat/phone-style
ST-DDT fbc61b3
Merge branch 'next' into feat/phone-style
ST-DDT d6dbf8f
Merge branch 'next' into feat/phone-style
ST-DDT 7b8bcd6
Merge branch 'next' into feat/phone-style
ST-DDT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. | ||
- - `'raw'`: A phone number in a raw international forma 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* This file is automatically generated. | ||
* Run 'pnpm run generate:locales' to update. | ||
*/ | ||
import type { PhoneNumberDefinition } from '../../../..'; | ||
import human from './human'; | ||
import national from './national'; | ||
import raw from './raw'; | ||
|
||
const format: PhoneNumberDefinition['format'] = { | ||
human, | ||
national, | ||
raw, | ||
}; | ||
|
||
export default format; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default [ | ||
'1#########', | ||
'2#########', | ||
'3#########', | ||
'4#########', | ||
'5#########', | ||
'080 0## ####', | ||
'0860 ### ###', | ||
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default [ | ||
'+271#########', | ||
'+272#########', | ||
'+273#########', | ||
'+274#########', | ||
'+275#########', | ||
'+27800######', | ||
'+27860######', | ||
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matthewmayer marked this conversation as resolved.
Show resolved
Hide resolved
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* This file is automatically generated. | ||
* Run 'pnpm run generate:locales' to update. | ||
*/ | ||
import type { PhoneNumberDefinition } from '../../../..'; | ||
import human from './human'; | ||
import national from './national'; | ||
import raw from './raw'; | ||
|
||
const format: PhoneNumberDefinition['format'] = { | ||
human, | ||
national, | ||
raw, | ||
}; | ||
|
||
export default format; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default ['9#########']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default ['+9949#########']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* This file is automatically generated. | ||
* Run 'pnpm run generate:locales' to update. | ||
*/ | ||
import type { PhoneNumberDefinition } from '../../../..'; | ||
import human from './human'; | ||
import national from './national'; | ||
import raw from './raw'; | ||
|
||
const format: PhoneNumberDefinition['format'] = { | ||
human, | ||
national, | ||
raw, | ||
}; | ||
|
||
export default format; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default ['601 ### ###', '737 ### ###', '736 ### ###', '### ### ###']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default [ | ||
'+420601######', | ||
'+420737######', | ||
'+420736######', | ||
'+420#########', | ||
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* This file is automatically generated. | ||
* Run 'pnpm run generate:locales' to update. | ||
*/ | ||
import type { PhoneNumberDefinition } from '../../../..'; | ||
import human from './human'; | ||
import national from './national'; | ||
import raw from './raw'; | ||
|
||
const format: PhoneNumberDefinition['format'] = { | ||
human, | ||
national, | ||
raw, | ||
}; | ||
|
||
export default format; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default ['!# ## ## ##']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default ['+45!#######']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* This file is automatically generated. | ||
* Run 'pnpm run generate:locales' to update. | ||
*/ | ||
import type { PhoneNumberDefinition } from '../../../..'; | ||
import human from './human'; | ||
import national from './national'; | ||
import raw from './raw'; | ||
|
||
const format: PhoneNumberDefinition['format'] = { | ||
human, | ||
national, | ||
raw, | ||
}; | ||
|
||
export default format; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default ['0#### ########', '0#### #######', '0#### ######']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default ['+49############', '+49###########', '+49##########']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* This file is automatically generated. | ||
* Run 'pnpm run generate:locales' to update. | ||
*/ | ||
import type { PhoneNumberDefinition } from '../../../..'; | ||
import human from './human'; | ||
import national from './national'; | ||
import raw from './raw'; | ||
|
||
const format: PhoneNumberDefinition['format'] = { | ||
human, | ||
national, | ||
raw, | ||
}; | ||
|
||
export default format; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default ['01 #######', '0#### ####', '0#### #####']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default ['+431#######', '+43########', '+43#########']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* This file is automatically generated. | ||
* Run 'pnpm run generate:locales' to update. | ||
*/ | ||
import type { PhoneNumberDefinition } from '../../../..'; | ||
import human from './human'; | ||
import national from './national'; | ||
import raw from './raw'; | ||
|
||
const format: PhoneNumberDefinition['format'] = { | ||
human, | ||
national, | ||
raw, | ||
}; | ||
|
||
export default format; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default [ | ||
'0800 ### ###', | ||
'0## ### ## ##', | ||
'0900 ### ###', | ||
'076 ### ## ##', | ||
'078 ### ## ##', | ||
'079 ### ## ##', | ||
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default [ | ||
'+41800######', | ||
'+41#########', | ||
'+41900######', | ||
'+4176#######', | ||
'+4178#######', | ||
'+4179#######', | ||
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* This file is automatically generated. | ||
* Run 'pnpm run generate:locales' to update. | ||
*/ | ||
import type { PhoneNumberDefinition } from '../../../..'; | ||
import human from './human'; | ||
import national from './national'; | ||
import raw from './raw'; | ||
|
||
const format: PhoneNumberDefinition['format'] = { | ||
human, | ||
national, | ||
raw, | ||
}; | ||
|
||
export default format; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default [ | ||
'3##-####', | ||
'4##-####', | ||
'5######', | ||
'6##-####', | ||
'7##-####', | ||
'8######', | ||
'9##-####', | ||
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default [ | ||
'+9603######', | ||
'+9604######', | ||
'+9605######', | ||
'+9606######', | ||
'+9607######', | ||
'+9608######', | ||
'+9609######', | ||
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.