function twilio_register_validate in Twilio 7
Custom validation function for phone numbers during registration.
1 string reference to 'twilio_register_validate'
- twilio_form_user_register_form_alter in ./
twilio.user.inc - Implements hook_FORMID_form_alter().
File
- ./
twilio.user.inc, line 125 - Twilio user account and registration related functionality
Code
function twilio_register_validate($form, &$form_state) {
$value = $form_state['values']['number'];
// Phone number is not required and not entered.
if (empty($value) && empty($form['account']['number']['#required'])) {
return;
}
// Something has been entered but is non numeric.
if (!is_numeric($value)) {
form_set_error('number', t('You must enter a valid phone number'));
}
elseif (twilio_verify_number($value)) {
form_set_error('number', t('This number is already in use and cannot be assigned to more than one account'));
}
}