Reputation: 3134
I am developing an application that would employ a server-side phone number validation for the various countries it is deployed in. As an example, the UK mobile numbers all contain 11 digits starting with 07. In another country the mobile numbers may contain a different number of digits or may start with a different code. I would like to use such country-specific phone number specification to validate the input of a web form. Please, note that the application will be deployed separately for each country. So for the UK version of the application a number starting with 099 or containing just 10 digits shall raise a submission error (e.g. "Invalid mobile phone number") whereas, say, the German version of the application shall not raise an error at all.
What is the most elegant way to implement such locale-specific form validation? I had a look at the i18n gem but I am not sure it would easily support it.
Upvotes: 0
Views: 66
Reputation: 1144
If your validation is server side, may be you can take a look at joost/phony_rails
I quote the description : This Gem adds useful methods to your Rails app to validate, display and save phone numbers. It uses the super awesome Phony gem
Upvotes: 1