Here is the code provided in the gump.php file, distributed with PHPRad. How do I access this for VALIDATION of an input field?
Surely there must be a way to use this function (and others inside gump.php)!
/**
* Determine if the provided value is a valid phone number.
*
* Usage: '<index>' => 'phone_number'
*
* @param string $field
* @param array $input
*
* @return mixed
*
* Examples:
*
* 555-555-5555: valid
* 5555425555: valid
* 555 555 5555: valid
* 1(519) 555-4444: valid
* 1 (519) 555-4422: valid
* 1-555-555-5555: valid
* 1-(555)-555-5555: valid
*/
protected function validate_phone_number($field, $input, $param = null)
{
if (!isset($input[$field]) || empty($input[$field])) {
return;
}
$regex = '/^(\d[\s-]?)?[\(\[\s-]{0,2}?\d{3}[\)\]\s-]{0,2}?\d{3}[\s-]?\d{4}$/i';
if (!preg_match($regex, $input[$field])) {
return array(
'field' => $field,
'value' => $input[$field],
'rule' => __FUNCTION__,
'param' => $param,
);
}
}