Hello,

I am using this phone module and I realized it doesn't support Finland phone numbers.

So I here is a patch which implements validation for Finland phone numbers.

Here is the details of the regular expression used here:
Start with either a local or international identifier:
* local identifier: 0
* International identifier: starting with + or 00 followed by an optional space and 358 which is Finland international prefix, plus another optional space here

Then the geographic or non-geographic code:
* Is composed of two digit from 10 to 99. Need some adjustment

Then 2 series of 2 to 4 digits and 1 optional serie of 1 to 3 digits, all optionally separated by spaces

source: http://en.wikipedia.org/wiki/Telephone_numbers_in_Finland

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

theo_’s picture

MauPalantir’s picture

I noticed some weird check on the regexp results which invalidated basically any phone number you entered, so removed them.

MauPalantir’s picture

Testing the patch I found another bug because the country code / 0 is attached to the whole phone number string, and if it was enered already in this format, then these prefixes are duplicated. Attached a patch version including the fix.

MauPalantir’s picture

Testing the patch I found another bug because the country code / 0 is attached to the whole phone number string, and if it was enered already in this format, then these prefixes are duplicated. Attached a patch version including the fix.

MauPalantir’s picture

Found another bug so the regexp does not accept an extra 0 after the country code if the code is provided. Also did some refactoring so the matches array doesnt capture the prefixes or whitespaces, to make formatting easier.