gump.class.php
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,
            );
        }
    }
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,
            );
        }
    }
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 , ) ; } }
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
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
Determine if the provided value is a valid phone number .