/**
  * @dataProvider data
  */
 public function test_filter($prefix, $postfix, $comp, $val, $e_sql, $e_opt)
 {
     $QB = new QueryBuilder();
     $text = new Text(array('prefix' => $prefix, 'postfix' => $postfix));
     $text->filter($QB, 'T', 'col', $comp, $val, 'AND');
     list($sql, $opt) = $QB->getWhereSQL();
     $this->assertEquals($this->cleanWS($e_sql), $this->cleanWS($sql));
     $this->assertEquals($e_opt, $opt);
 }
 /**
  * Validate
  *
  * @param int|string $rawvalue
  * @return int|string
  */
 public function validate($rawvalue)
 {
     $rawvalue = parent::validate($rawvalue);
     $mail = $this->config['prefix'] . $rawvalue . $this->config['postfix'];
     if (!mail_isvalid($mail)) {
         throw new ValidationException('Mail invalid', $mail);
     }
     return $rawvalue;
 }
Example #3
0
 /**
  * The final string should be an URL
  *
  * @param string $rawvalue
  * @return int|string|void
  */
 public function validate($rawvalue)
 {
     $rawvalue = parent::validate($rawvalue);
     $url = $this->buildURL($rawvalue);
     $schemes = getSchemes();
     $regex = '^(' . join('|', $schemes) . '):\\/\\/.+';
     if (!preg_match("/{$regex}/i", $url)) {
         throw new ValidationException('Url invalid', $url);
     }
     return $rawvalue;
 }