/**
  * @todo Implement testIsRegex().
  */
 public function testIsRegex()
 {
     $input = 'username_786';
     $regex = '/[a-zA-Z0-9_]/';
     $this->assertTrue(Inspekt::isRegex($input, $regex));
 }
Exemple #2
0
 /**
  * Returns value if it matches $pattern, FALSE otherwise. Uses
  * preg_match() for the matching.
  *
  * @param mixed $key
  * @param mixed $pattern
  * @return mixed
  *
  * @tag validator
  */
 function testRegex($key, $pattern = NULL)
 {
     if (!$this->keyExists($key)) {
         return false;
     }
     if (Inspekt::isRegex($this->_getValue($key), $pattern)) {
         return $this->_getValue($key);
     }
     return FALSE;
 }
Exemple #3
0
 /**
  * Returns value if it matches $pattern, FALSE otherwise. Uses
  * preg_match() for the matching.
  *
  * @param mixed $key
  * @param mixed $pattern
  * @return mixed
  * @throws Exception
  * @tag validator
  */
 public function testRegex($key, $pattern)
 {
     $value = $this->getValueOrNull($key);
     if (!is_null($value) && Inspekt::isRegex($value, $pattern)) {
         return $value;
     }
     return false;
 }