Skip to content

Consistent addresses #2881

Open
Open
@jaredbeck

Description

@jaredbeck

Is your feature request related to a problem? Please describe it.

It is difficult to generate an address meeting the basic standards of consistency. For example, we may want the state and state_abbr to match.

If you're adding new objects, please describe how you would use them
Provide examples of how the proposed feature could be useful and relevant.
For example, if proposing a new generator, explain why it's useful and relevant to Faker, and examples of how to use it in a real project.

Many systems perform basic validation of addresses. It would be convenient if Faker::Address could pass basic validation. I'd suggest that it is outside the scope of Faker to pass advanced validation, e.g. geocoding or postal-service validation.

Describe alternatives you've considered

I tried using full_address_as_hash,

Faker::Address.full_address_as_hash(:street_address, :city, :country, :country_code, :state, :state_abbr, :zip_code, :longitude, :latitude, :country_name_to_code, country_name_to_code: {name: 'united_states'})
#=> {:street_address=>"9158 Gerhold Track", :city=>"North Kelly", :country=>"Albania", :country_code=>"BQ", :state=>"Montana", :state_abbr=>"NC", :zip_code=>"38817-0927", :longitude=>138.93577082675893, :latitude=>83.71634642320669, :country_name_to_code=>"US"}
irb(main):014:0> 

We can see multiple inconsistencies in the above. For example, "US" does not match "Albania".

I am not proposing to change the behavior of .full_address_as_hash, it is just an example of an alternative I considered.

It is possible for users to build their own "consistency layer" on top of Faker, but is not convenient.

Additional context

I will be happy to attempt a PR, if this feature is approved.

For backwards compatibility, this new feature would be an addition, with no breaking changes.

I've deliberately avoided suggesting a new API, as I don't have any opinions about the names of e.g. new methods. I am just seeking feature approval at this point.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions