-
Notifications
You must be signed in to change notification settings - Fork 363
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
Comments
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 |
So this would then mean that you'd prefer a solution where
To be 100% valid |
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 |
Alright, then I'll implement a change where
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 |
Okay, than I'll just take the easier path and replace the existing randomly generated postcode with valid ones. |
In de_AT/Address.php there's a TODO comment to implement more strict postal code values:
Faker/src/Faker/Provider/de_AT/Address.php
Lines 16 to 17 in 6027e18
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
Faker/src/Faker/Provider/de_AT/Address.php
Line 97 in d55d5aa
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)?
The text was updated successfully, but these errors were encountered: