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

Add method to generate a full address #2011

Open
matthewmayer opened this issue Apr 2, 2023 · 9 comments
Open

Add method to generate a full address #2011

matthewmayer opened this issue Apr 2, 2023 · 9 comments
Assignees
Labels
c: feature Request for new feature m: location Something is referring to the location module s: waiting for user interest Waiting for more users interested in this feature
Milestone

Comments

@matthewmayer
Copy link
Contributor

Clear and concise description of the problem

There's no way to generate a "full" address e.g. street, city, state and ZIP together in a locale-aware way.

Different locales write addresses differently, e.g. in some locales you write secondary address before street address, in others vice versa. In some locales you write ZIP code/postcode together with city, in others you write on a seperate line, and some locales dont have ZIPs at all. Some locales go "most to least specific" (e.g. en_US) and some go "least to most specific" (e.g. zh_CN). Some locales utilize the secondary admin area (e.g. county) and some don't.

Suggested solution

Implement faker.location.address() or faker.location.fullAddress() and an associated definition pattern for each locale which might combine some or all of

  • streetAddress
  • city
  • county
  • state
  • stateAbbr
  • zipCode

Alternative

manually construct address from the pieces, but then if you change locales you have to change the pattern.

Additional context

Might need the option to do it as a single line address or multiline

@matthewmayer matthewmayer added the s: pending triage Pending Triage label Apr 2, 2023
@matthewmayer matthewmayer self-assigned this Apr 2, 2023
@matthewmayer matthewmayer added s: needs decision Needs team/maintainer decision m: location Something is referring to the location module c: feature Request for new feature labels Apr 2, 2023
@matthewmayer matthewmayer moved this to Todo in Faker Roadmap Apr 2, 2023
@ST-DDT
Copy link
Member

ST-DDT commented Apr 2, 2023

I think we should refer to it for what it used for e.g. fullPostalAddress.
Since we don't return dynamic objects it would return a multi line string.

@ST-DDT
Copy link
Member

ST-DDT commented Apr 2, 2023

If you are interested in this feature please upvote the top comment, so we know which feature we should focus on. We will consider implementing the feature if it gets enough upvotes.

@ST-DDT ST-DDT added s: waiting for user interest Waiting for more users interested in this feature and removed s: pending triage Pending Triage s: needs decision Needs team/maintainer decision labels Apr 2, 2023
@mylysddp
Copy link

mylysddp commented May 14, 2023

I have also encountered similar problems. If a complete address cannot be generated, it will lead to a lack of logical relationship between the addresses. For example, the country does not match the state, or the state does not match the city.

@mylysddp
Copy link

Is it possible to add a method to generate complete addresses that allows me to input the name of a country, state, or city, or a postal code, and then generate corresponding city data based on the parameters I pass in?

@matthewmayer
Copy link
Contributor Author

matthewmayer commented May 14, 2023

I think the goal of Faker is to generate plausible-looking rather than necessarily consistent/realistic data.

Making realistic data would require much more complex logic for each country/locale which I think is out of scope of Faker.

@mylysddp
Copy link

"If the data provided is real, the requirements for faker-js will indeed be higher. However, could we consider covering data from several larger countries such as the United States, China, Russia, Canada, etc.?

@dgodonjf
Copy link

dgodonjf commented Sep 3, 2024

I get not wanting to push Faker into fully realistic data, but I it would be helpful to better support some basic consistency options similar to how states get filtered by country and how zip code can be filtered by state. A couple of ideas: allow restricting city by state, and provide option to get a state and abbreviated state to align

@matthewmayer
Copy link
Contributor Author

provide option to get a state and abbreviated state to align

Please upvote #2349 if you are interested in this

@matthewmayer
Copy link
Contributor Author

Allow restricting city by state

This is trickier because city names are not necessarily real cities in all locales. In many cases they are patterns like FirstName + suffix eg Matthewville.

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 m: location Something is referring to the location module s: waiting for user interest Waiting for more users interested in this feature
Projects
No open projects
Status: Todo
Development

No branches or pull requests

4 participants