When creating a validation rule of type "Postal Code" (provided by Field validation extras sub-module), you can't select more than one country to validate against.

Use case: I want to allow users to enter either US or Canada ZIP code into the field.

Desired behaviour: multi select Country field at Postal Code validation rule setting screen. If ZIP validates against at least one of the countries selected, than field value is considered valid.

Let me know if it's something that can be achieved in a different way (multiple validation rules - one for each country?). If it's impossible, I will publish a patch here I created for my project.

Thanks for all the great work done on this module.

Comments

Kevin Morse’s picture

Issue summary: View changes

So I had this issue as well and after looking into the actual code of the validator (field_validation_postal_code_validator.inc) I saw that there is an option called autodetect which takes the Country from the Address Field and uses that for the validation.

This should solve your problem.

I think it would be beneficial to have this option selected by default and/or renamed to reflect what it actually does.

Perhaps it could be called "Use Country provided by Address Field"