Exemple #1
0
 public function isValid($value)
 {
     if (!empty($this->_phone)) {
         $value = $this->_phone;
     }
     // this line populates the "%value%" variables in the error messages
     $this->_setValue($value);
     // check format
     if (!Inspekt::isPhone($value)) {
         // this line will insert the error message in the list of errors to
         // be returned to the caller
         $this->_error(self::NOT_PHONE);
         return false;
     }
     return true;
 }
Exemple #2
0
 /**
  * Returns value if it is a valid phone number format, FALSE
  * otherwise. The optional second argument indicates the country.
  *
  * @param mixed $key
  * @return mixed
  *
  * @tag validator
  */
 function testPhone($key, $country = 'US')
 {
     if (!$this->keyExists($key)) {
         return false;
     }
     if (Inspekt::isPhone($this->_getValue($key), $country)) {
         return $this->_getValue($key);
     }
     return FALSE;
 }
 /**
  * 
  */
 public function testIsPhone()
 {
     $input = '7655559090';
     $this->assertTrue(Inspekt::isPhone($input));
 }
Exemple #4
0
 /**
  * Returns value if it is a valid phone number format, FALSE
  * otherwise. The optional second argument indicates the country.
  *
  * @param mixed $key
  * @param string $country
  * @return mixed
  * @throws Exception
  * @tag validator
  */
 public function testPhone($key, $country = 'US')
 {
     $value = $this->getValueOrNull($key);
     if (!is_null($value) && Inspekt::isPhone($value, $country)) {
         return $value;
     }
     return false;
 }