Really like the direction this module is taking and have been following its progress.
With the recent commit of Twilio as an SMS plugin, I've been keen to test this. I am not based in the US and when I attempt to set the value of the Mobile number, it return an error: "Number does not match expected patterns". I've tried various formats of an acceptable mobile number in South Africa and for that matter, other territories. I think the validation of this number is too restrictive for general use.
Without being able to enter a valid number which I have access to, I'm not able to test the implementation of this further.
Comments
Comment #1
coltraneThanks very much for your interest in this! I don't mean to only support the NAN system but current requirements only support US/CA numbers. It's briefly mentioned in the readme (http://cgit.drupalcode.org/tfa_basic/plain/README.txt) but you can validate and allow other number styles with hooks hook_tfa_basic_valid_number_alter() and hook_tfa_basic_format_number_alter(). Let me know how this works for you!
Comment #2
coltraneMarking closed. Feel free to re-open if there's a problem with the existing hooks or suggestion for wider support.
Comment #3
johnkareoke commented@coltrane
I've tried to create a module that implements both hook_tfa_basic_valid_number_alter() and hook_tfa_basic_format_number_alter() to validate and format the numbers for my intended audience. Bearing in mind that this is the first module I've written, I'd appreciate if you can take a glance at it below and tell me if there is something that is obviously wrong. I've tested the regex pattern and know it works, but I simply get a WSOD when I attempt to add an number for SMS.
I may simply be implementing these hooks incorrectly.
Any help is much appreciated.
tfa_rsa_number.info
name = tfa_rsa_number
description = This module allows South African Number to be used with the TFA basic plugin.
core = 7.x
dependencies = tfa, tfa_basic
tfa_rsa_number.module
Comment #4
klausiThe drupal_alter() hook in tfa_basic_valid_number() cannot work, because it does not pass the $alterable array, fixed that.
Then I think we should introduce a tfa_basic_sms_nanp_validate variable which allows site owners to opt out of the NANP validation. It defaults to 1, so nothing changes for existing installations, they still get NANP validated.
This is a very basic requirement for international users and I rather do a pretty small tfa_basic patch than writing a module for that.
Comment #5
gregglesThat solution in #4 makes sense to me as an easy solution for those who don't want validation or don't want to write validation code.
Comment #7
coltrane@klausi, thanks for catching that alterables wasn't correctly passed in. I like this approach and tests pass so I've committed the patch in #4. Marking fixed.