Skip to content

Improve specification of Address.countryCode() #648

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

Closed
ST-DDT opened this issue Mar 21, 2022 · 3 comments · Fixed by #752
Closed

Improve specification of Address.countryCode() #648

ST-DDT opened this issue Mar 21, 2022 · 3 comments · Fixed by #752
Assignees
Labels
c: bug Something isn't working c: docs Improvements or additions to documentation c: locale Permutes locale definitions p: 2-high Fix main branch s: accepted Accepted feature / Confirmed bug

Comments

@ST-DDT
Copy link
Member

ST-DDT commented Mar 21, 2022

faker/src/address.ts

Lines 277 to 288 in 5642470

/**
* Returns a random country code.
*
* @param alphaCode The code to return. Can be either `'alpha-2'` (2 letter code)
* or `'alpha-3'` (three letter code). Defaults to `'alpha-2'`.
*
* @example
* faker.address.countryCode() // 'SJ'
* faker.address.countryCode('alpha-2') // 'GA'
* faker.address.countryCode('alpha-3') // 'TJK'
* faker.address.countryCode('unsupported') // 'DJ'
*/

/**
* The ISO-3166-1 ALPHA-2 country codes
*/
country_code: string[];
/**
* The ISO-3166-1 ALPHA-3 country codes
*/
country_code_alpha_3: string[];

Currently it is not clear whether the method should return a country code related to that locale/language or any of the world.
We should decide on either of these and thus adjust the documentation.

Affects:

  • src/locales/de_CH/address/country_code.ts (Related to the locale)
  • src/locales/fa/address/country_code.ts (Duplicates en)
  • src/locales/fr_CH/address/country_code.ts (Related to the locale)
  • src/locales/he/address/country_code.ts (Empty/Invalid)
  • Respective alpha3 files

If we use "any of the world" these files have to be deleted. ( * -> anyof ['AZ', ..., 'ZY'])
If we use "related to that locale" we have to update them. ( de -> anyof ['CH', 'DE'])

Blocks #609

@ST-DDT ST-DDT added c: bug Something isn't working c: docs Improvements or additions to documentation p: 2-high Fix main branch s: needs decision Needs team/maintainer decision c: locale Permutes locale definitions labels Mar 21, 2022
@ST-DDT ST-DDT added this to the v6.1 - First bugfixes milestone Mar 21, 2022
@ST-DDT ST-DDT moved this to Todo in Faker Roadmap Mar 21, 2022
@ST-DDT
Copy link
Member Author

ST-DDT commented Mar 21, 2022

If we limit it to "related to that locale" ( de -> anyof ['CH', 'DE']), then we have to apply the same logic to some of the other methods too, such as iban generation.

@Shinigami92
Copy link
Member

Maybe this issue is so huge, that we should put it on agenda for team meeting 🤔

@ST-DDT
Copy link
Member Author

ST-DDT commented Apr 1, 2022

In our last team meeting we decided to let the locale decide which countries to return.
I will create a PR that removes the invalid files.

@ST-DDT ST-DDT self-assigned this Apr 1, 2022
@ST-DDT ST-DDT added s: accepted Accepted feature / Confirmed bug and removed s: needs decision Needs team/maintainer decision labels Apr 1, 2022
Repository owner moved this from Todo to Done in Faker Roadmap Apr 1, 2022
@ST-DDT ST-DDT removed this from Faker Roadmap Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working c: docs Improvements or additions to documentation c: locale Permutes locale definitions p: 2-high Fix main branch s: accepted Accepted feature / Confirmed bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants