Hello, I checkout the CVS head version and code a Brazilian phone format, based on the French .inc file.
This accept the following formats:
- 55 11 3344 5566
- 011 3344 5566
- 11 3344 5566
with optionally any ( ), + and - separators.
I hope you like it.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 416200-brazilian_phone-3.patch | 5.91 KB | develcuy |
| #3 | phone-br-6.x-2.7.patch | 6.41 KB | danillonunes |
| #3 | phone-br-HEAD.patch | 6.85 KB | danillonunes |
| #1 | 416200-brazilian_phone-2.patch | 4.39 KB | develcuy |
| brazilian_phone.patch | 5.51 KB | danillonunes |
Comments
Comment #1
develcuy commentedI have re-rolled the patch for HEAD and added more test cases:
+55 11 888 9999
+55 11 8888 9999
0055 11 888 9999
0055 11 8888 9999
55 11 888 9999
55 11 8888 9999
Notice that some brazilian phone numbers still use 7 digits format.
Comment #2
danillonunes commentedApparently you forgot to include the .inc file in your patch.
Comment #3
danillonunes commentedI add options to select separators and use of parentheses in BR phones, like the Canadians.
Also, I make too a patch to 6.x-2.7 version.
Also, now all this formats are valids:
with optionally any ( ), + and - separators that are irrelevants, the final result is formatted as defined by admin.
Thanks to develCuy for help with regex.
Comment #4
develcuy commented@danillonunes, I don't agree with your approach. See the implementation for other countries in this module, they don't suppress characters from the text AFAIK.
It is supposed that a validation checks the data, this should not alter the data.
ATM, your patch thinks following phones are valid>
Those are so far not valid phone numbers.
Here is my patch including the missing file. Please take a look.
Blessings!
Comment #5
danillonunes commenteddevelCuy, the implementation of French format, which I uses as basis for developing the Brazilian format, removes too non-numeric separator characters.
It changes the data because it is not just a validation (did you look the format_br_phone_number function?), but a validation followed by a formatting, which ensures that all data received are stored in a standard way - regardless of format they were received (as a validation of URL will accept an address as "google.com" and will change it to "http://google.com").
I don't consider the possibility that the user enters something like "11+888()99(99+". Really, I think it is very improbably that he type it, but if for some reason this really happen, I think it is better that the module can understand and process this information in an intelligent way (it will format it as "(11) 888-9999") than say it is invalid and ask the user to type in the right way - is less work for the user that probably was already fully drunken to have entered something like it. ;)
BTW, I found that the Brazilian phones with 7 digits are already obsolete, now the standard is 8 digits in everywhere. I'm sorry for giving you a wrong information.
Comment #6
thierry_gd commentedTaken into account in 6.2.9 version