Cake\Localized\Validation\RuValidation::phone PHP Method

phone() public static method

Checks phone number for Russia
public static phone ( string $check ) : boolean
$check string The value to check.
return boolean Success.
    public static function phone($check)
    {
        $pattern = '/^\\+7 \\(\\d+\\) \\d{3,}$/';
        return (bool) preg_match($pattern, $check);
    }

Usage Example

Beispiel #1
0
 /**
  * test phone method of RuValidation
  *
  * @return void
  */
 public function testPhone()
 {
     $this->assertTrue(RuValidation::phone('+7 (342) 1234567'));
     $this->assertTrue(RuValidation::phone('+7 (41144) 1234'));
 }