Skip to content
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

Change address.countryCode method signature #587

Closed
xDivisionByZerox opened this issue Mar 1, 2022 · 3 comments · Fixed by #588
Closed

Change address.countryCode method signature #587

xDivisionByZerox opened this issue Mar 1, 2022 · 3 comments · Fixed by #588
Assignees
Labels
c: feature Request for new feature p: 1-normal Nothing urgent

Comments

@xDivisionByZerox
Copy link
Member

The Problem

Existing comment about this issue:
By @ST-DDT: Limit the parameter to the two values.

faker/src/address.ts

Lines 289 to 306 in f476859

// TODO ST-DDT 2022-02-10: Limit the parameter to the two values.
countryCode(alphaCode: string = 'alpha-2'): string {
if (alphaCode === 'alpha-2') {
return this.faker.random.arrayElement(
this.faker.definitions.address.country_code
);
}
if (alphaCode === 'alpha-3') {
return this.faker.random.arrayElement(
this.faker.definitions.address.country_code_alpha_3
);
}
return this.faker.random.arrayElement(
this.faker.definitions.address.country_code
);
}

The Solution

Only except 'alpha-2' and 'alpha-3' as valid string inputs

countryCode(alphaCode: 'alpha-2' | 'alpha-3' = 'alpha-2'): string
@xDivisionByZerox xDivisionByZerox added the s: pending triage Pending Triage label Mar 1, 2022
@ST-DDT ST-DDT added c: feature Request for new feature and removed s: pending triage Pending Triage labels Mar 1, 2022
@ST-DDT ST-DDT added this to the v6.1 - First bugfixes milestone Mar 1, 2022
@ST-DDT ST-DDT moved this to Todo in Faker Roadmap Mar 1, 2022
@ST-DDT
Copy link
Member

ST-DDT commented Mar 1, 2022

Not sure, whether this should be in v6.1 or v6.2,

@xDivisionByZerox
Copy link
Member Author

We could first put this in v6.2. But can put in v6.1 if we magically get everything else done?^^

@xDivisionByZerox
Copy link
Member Author

I provided a PR that fixes this. Please assign me to this issue.

@ST-DDT ST-DDT moved this from Todo to Awaiting Review in Faker Roadmap Mar 2, 2022
@ejcheng ejcheng added the p: 1-normal Nothing urgent label Mar 15, 2022
Repository owner moved this from Awaiting Review to Done in Faker Roadmap Apr 5, 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: feature Request for new feature p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants