-
-
Notifications
You must be signed in to change notification settings - Fork 953
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
Comments
I think we should refer to it for what it used for e.g. fullPostalAddress. |
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. |
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. |
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? |
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. |
"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.? |
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 |
Please upvote #2349 if you are interested in this |
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. |
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
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
The text was updated successfully, but these errors were encountered: