Given that the "built-in" contact editing form allows you to choose State-Province values based on the Country you select - and IGNORES the "Available State-Provinces" config setting - we should modify the Contact IMPORT validation logic to be consistent with the Edit form behavior.
State-province input values are valid if:
- The value matches a row in the state_province table AND it "belongs" to a country in the Available Countries config setting.
- If a Country value is also present in input row - we should also validate that the State-province BELONGS to the specified country.
I think we are already validating that an import Country field value is in the Available Countries config setting - but please verify. Please differentiate the error messages for the two cases:
- Case 1 - country input value not in country table: "The Country value appears to be invalid. I does not match any value in CiviCRM table of countries."
- Case 2 - country input is in table but not "available": "This Country is valid but is NOT in the list of Available Countries currently configured for your site. This can be viewed and modifed from Global Settings >> Localization."
— Original post --------
The localization preferences state under Available States and Provinces:
"Which countries' states and/or provinces are available in the State / Province selection field for Custom Fields and Profile forms. (Standard contact address editing forms automatically display corresponding state / province options for the selected country.)"
However, when importing, valid state/province data is rejected when the country is not selected in that preference. In other words, when importing U.K. address data, all contacts with a valid provinces are flagged as errors unless the U.K. is selected in the available states and provinces, despite what the help text says.