Brazilian format support
danillonunes - March 27, 2009 - 22:47
| Project: | Phone (CCK) |
| Version: | HEAD |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | danillonunes |
| Status: | closed |
Description
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.
| Attachment | Size |
|---|---|
| brazilian_phone.patch | 5.51 KB |

#1
I 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.
#2
Apparently you forgot to include the .inc file in your patch.
#3
I 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.
#4
@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!
#5
develCuy, 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.
#6
Taken into account in 6.2.9 version
#7
Automatically closed -- issue fixed for 2 weeks with no activity.