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

Stricter postcodes for AT? #77

Closed
krsriq opened this issue Nov 28, 2020 · 6 comments · Fixed by #86
Closed

Stricter postcodes for AT? #77

krsriq opened this issue Nov 28, 2020 · 6 comments · Fixed by #86
Labels
bug Something isn't working

Comments

@krsriq
Copy link

krsriq commented Nov 28, 2020

In de_AT/Address.php there's a TODO comment to implement more strict postal code values:

// As per https://en.wikipedia.org/wiki/List_of_postal_codes_in_Austria (@todo implement more strict postal code values according to wikipedia)
protected static $postcode = [

I looked through the other address providers - some have a list of (presumably) all available postcodes (such as en_GB), some use numerify/regex to generate postcodes (such as en_AU), others use completely random numbers.

Does it make sense to have a list of all valid postal codes hard coded, as the comment suggests? Especially since a generated address would then still be likely invalid, because it's a random combination of a postal code and a city

"{{streetAddress}}\n{{postcode}} {{city}}",

So one possible solution would be to just remove that TODO comment and live with invalid postal codes, or to hard code all available postal codes (and still live with invalid postal code/city combinations).
A more advanced solution would be to build a data structure that has a hierarchy of state-postcode-city, so only valid combinations are possible - but that would probably be overkill (and a solution I couldn't find in any other providers)?

@pimjansen
Copy link

Imo a faker method should return valid data. If it is invalid it is useless to start with.

So if that means a lot of logic, then this is the case we have to deal with

@pimjansen pimjansen added the bug Something isn't working label Nov 29, 2020
@krsriq
Copy link
Author

krsriq commented Nov 29, 2020

So this would then mean that you'd prefer a solution where

  1. postcode() returns a valid postcode
  2. address() returns a valid postcode-city combination?

To be 100% valid address() would of course also have to be a valid street-postcode-city combination, meaning a pretty extensive list of valid streets per city..

@pimjansen
Copy link

So this would then mean that you'd prefer a solution where

  1. postcode() returns a valid postcode
  2. address() returns a valid postcode-city combination?

To be 100% valid address() would of course also have to be a valid street-postcode-city combination, meaning a pretty extensive list of valid streets per city..

Well we create fake data. This means that dummy names can be used there. However if we can build something that is more realistic it would always be good.

The most important thing imo is the format though

@krsriq
Copy link
Author

krsriq commented Nov 29, 2020

Alright, then I'll implement a change where

  1. postcode() returns a random existing postcode
  2. address() returns a valid postcode-city combination while keeping the format "{{streetAddress}}\n{{postcode}} {{city}}", so streetAdress will remain fake.

Cool?

@pimjansen
Copy link

pimjansen commented Nov 29, 2020

Alright, then I'll implement a change where

  1. postcode() returns a random existing postcode
  2. address() returns a valid postcode-city combination while keeping the format "{{streetAddress}}\n{{postcode}} {{city}}", so streetAdress will remain fake.

Cool?

Sounds good though its hard for me to decide where i have no clue how postalcodes in austria work.

But if you generate a valid postalcode city combination, the postalcode can also be valid from the same list right?

But we generate fake data. I do not really care much if a city name matches the postalcode where it is fake data. Meaning as long as the format is good im fine actually

@krsriq
Copy link
Author

krsriq commented Nov 30, 2020

Okay, than I'll just take the easier path and replace the existing randomly generated postcode with valid ones.

@krsriq krsriq mentioned this issue Nov 30, 2020
3 tasks
@bram-pkg bram-pkg reopened this Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants