Currently I have regular expression for zip code for US
validates :zip, presence: true, format: { with: /\A\d{5}(-\d{4})?\z/ }
I want to use different regular expression for other country on the same field zip code so the regular expression should be use according to country
For Australia 4 digits
For Canada 6 digits alphanumeric
For UK 6-7 digits alphanumeric
Can some suggest to me how can I full fill my requirement. What are the way to achieve this.
Thank you in Advance for any kind of help and suggestion.
Aucun commentaire:
Enregistrer un commentaire