protected function doClean($value) { $value = parent::doClean($value); if (!preg_match($this->getPattern(), $value)) { throw new sfValidatorError($this, 'match', array('value' => $value)); } return $value; }
/** * @param mixed $value * @return mixed|string * @throws sfValidatorError */ protected function doClean($value) { $clean = parent::doClean($value); if (!DecisionTable::getInstance()->verifyAvailableNameByUserId($this->getOption('user_id'), $clean, $this->getOption('decision_id'))) { throw new sfValidatorError($this, 'busy_name'); } return $clean; }
protected function doClean($value) { $clean = parent::doClean($value); if ($clean != htmlspecialchars($clean, ENT_NOQUOTES)) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } return $clean; }
/** * @see sfValidatorString */ protected function doClean($value) { $clean = parent::doClean($value); if (!preg_match($this->getOption('pattern'), $clean)) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } return $clean; }
/** * @see sfValidatorUrl */ protected function doClean($value) { $value = parent::doClean($value); if ($value !== dmOs::sanitizeDirName($value)) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } return $value; }
protected function doClean($value) { $clean = parent::doClean($value); if ($clean != long2ip(ip2long($clean))) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } return $clean; }
protected function doClean($value) { $value = parent::doClean($value); $value = str_replace(array('-', '/', '\\', '_'), '', $value); if (!CuitVerifier::verify($value)) { throw new sfValidatorError($this, 'invalid'); } return $value; }
/** * @see sfValidatorString */ protected function doClean($value) { $clean = parent::doClean($value); $pattern = $this->getPattern(); if ($this->getOption('must_match') && !preg_match($pattern, $clean) || !$this->getOption('must_match') && preg_match($pattern, $clean)) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } return $clean; }
/** * @see sfValidatorBase */ protected function doClean($value) { $clean = parent::doClean($value); $first = strtolower(trim(substr($clean, 0, strpos($clean, ' ')))); if (!in_array($first, $this->getOption('words'))) { throw new sfValidatorError($this, 'not_a_question', array('first' => $first)); } return $clean; }
/** * @see sfValidatorBase */ protected function doClean($value) { $clean = strtolower(trim($value)); if (!Utils::validPermalink($clean)) { //any error code is satisfactory throw new sfValidatorError($this, 'invalid', array()); } return parent::doClean($clean); }
/** * Checks that this is a valid class. */ protected function doClean($value) { $clean = parent::doClean($value); $match = BarbaraClassTable::getInstance()->findOneByTitle($clean); if (!$match) { throw new sfValidatorError($this, 'class', array('value' => $value)); } return $clean; }
protected function doClean($value) { $clean = $value; if ($this->getOption('required') && (!$value['postcode'] || !$value['city'] || !$value['address'])) { throw new sfValidatorError($this, 'A teljes cím megadása kötelező', array('value' => $value)); } $clean = $value['postcode'] . '|' . $value['city'] . '|' . $value['address']; parent::doClean($clean); return $clean; }
/** * @see sfValidatorUrl */ protected function doClean($value) { $value = parent::doClean($value); try { $array = sfYaml::load($value); } catch (InvalidArgumentException $e) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } return $value; }
function doClean($value) { $value = parent::doClean($value); foreach (explode('.', $value) as $num) { if (!is_numeric($num)) { throw new sfValidatorError($this, 'invalid', array('version' => $value)); } } return $value; }
/** * @see sfValidatorBase */ protected function doClean($value) { $clean = (string) $value; $clean = strtoupper($clean); if (!AdmorphousUtils::$usStates[$clean]) { //any error code is satisfactory throw new sfValidatorError($this, 'min_length', array()); } return parent::doClean($value); }
/** * @see sfValidatorString */ protected function doClean($value) { $clean = parent::doClean($value); if ($this->getOption('full_required') && !preg_match('/^(0[1-9]|[12]\\d|3[01])([04][1-9]|[15][0-2])\\d{7}$/', $clean)) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } if (!$this->getOption('full_required') && !preg_match('/^(0[1-9]|[12]\\d|3[01])([04][1-9]|[15][0-2])\\d{2}(\\d{5})?$/', $clean)) { throw new sfValidatorError($this, 'invalid2', array('value' => $value)); } return $clean; }
/** * @see sfValidatorBase */ protected function doClean($value) { $clean = (string) $value; $clean = Utils::safeSimpleStr($clean); $clean = strtolower($clean); parent::doClean($clean); if (!Utils::validUsername($clean)) { throw new sfValidatorError($this, 'invalid', array('value' => $clean)); } return $clean; }
/** * @see sfValidatorBase */ protected function doClean($value) { $clean = (string) $value; if ($this->getOption('strip')) { $clean = aHtml::simplify($clean, $this->getOptionOrFalse('allowed_tags'), $this->getOptionOrFalse('complete'), $this->getOptionOrFalse('allowed_attributes'), $this->getOptionOrFalse('allowed_styles')); } else { throw new sfException('That should not happen strip is set in configure in sfValidatorHtml'); } $clean = parent::doClean($clean); return $clean; }
protected function doClean($value) { $validatedString = parent::doClean($value); if ($this->hasOption('id')) { $specified_pass = ModeratorManagement::asMd5WithPrefix($validatedString); $former_pass = ModeratorManagement::getPasswordAsMd5($this->getOption('id')); if ($specified_pass != $former_pass) { throw new sfValidatorError($this, 'You have specified an invalid former password.'); } } else { throw new sfValidatorError($this, 'id'); } }
/** * @see sfValidatorBase */ protected function doClean($value) { $clean = (string) parent::doClean($value); $clean = aTools::strtolower($clean); $slugified = aTools::slugify($clean, $this->getOption('allow_slashes')); if ($this->getOption('strict')) { if ($slugified !== $clean) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } } else { $clean = $slugified; } return $clean; }
protected function doClean($value) { $value = parent::doClean($value); if (!preg_match('/[0-9]/', $value)) { throw new sfValidatorError($this, 'number'); } if (!preg_match('/[a-z]/', $value)) { throw new sfValidatorError($this, 'lower'); } if (!preg_match('/[A-Z]/', $value)) { throw new sfValidatorError($this, 'upper'); } return $value; }
protected function doClean($value) { $value = parent::doClean($value); $missing = array(); foreach ((array) $this->getOption('keywords') as $keyword) { if (strpos($value, $keyword) === false) { $missing[] = $keyword; } } if ($missing) { throw new sfValidatorError($this, 'missing', array('keywords' => implode(', ', $missing))); } return $value; }
/** * @see sfValidatorString */ protected function doClean($value) { $value = parent::doClean($value); if (!class_exists($value)) { throw new sfValidatorError($this, 'notfound', array('value' => $value)); } if ($this->hasOption('implements') && $value != $this->getOption('implements')) { $class = new ReflectionClass($value); if (!$class->isSubclassOf($this->getOption('implements'))) { throw new sfValidatorError($this, 'notimplement', array('value' => $value, 'implements' => $this->getOption('implements'))); } } return $value; }
protected function doClean($value) { $value = parent::doClean($value); switch ($this->getOption('version')) { case self::IP_V4: $flag = FILTER_FLAG_IPV4; break; case self::IP_V6: $flag = FILTER_FLAG_IPV6; break; case self::IP_V4_NO_PRIV: $flag = FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE; break; case self::IP_V6_NO_PRIV: $flag = FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE; break; case self::IP_ALL_NO_PRIV: $flag = FILTER_FLAG_NO_PRIV_RANGE; break; case self::IP_V4_NO_RES: $flag = FILTER_FLAG_IPV4 | FILTER_FLAG_NO_RES_RANGE; break; case self::IP_V6_NO_RES: $flag = FILTER_FLAG_IPV6 | FILTER_FLAG_NO_RES_RANGE; break; case self::IP_ALL_NO_RES: $flag = FILTER_FLAG_NO_RES_RANGE; break; case self::IP_V4_ONLY_PUBLIC: $flag = FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE; break; case self::IP_V6_ONLY_PUBLIC: $flag = FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE; break; case self::IP_ALL_ONLY_PUBLIC: $flag = FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE; break; default: $flag = null; break; } if (!filter_var($value, FILTER_VALIDATE_IP, $flag)) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } return $value; }
protected function doClean($value) { $value = parent::doClean($value); $pattern = '/^([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})$/i'; $list = preg_split("#[,\\s\n\r]+#", $value); $clean_list = array(); foreach ($list as $email) { $email = trim($email); if (empty($email)) { continue; } if (!preg_match($pattern, $email)) { throw new sfValidatorError($this, 'invalid', array('value' => $email)); } $clean_list[] = $email; } return $clean_list; }
/** * @see sfValidatorString */ protected function doClean($value) { // clean by the parent $clean = parent::doClean($value); $numVal = new sfValidatorNumber(array('required' => false, 'min' => $this->getOption('min'), 'max' => $this->getOption('max'))); $numVal->clean($value); // get the option $separator = $this->getOption('separator'); $max_left = $this->getOption('max_left'); $max_right = $this->getOption('max_right'); // build the regexp to test $pattern = '/^\\d{1,' . $max_left . '}'; $pattern .= '(\\' . $separator; $pattern .= '\\d{0,' . $max_right . '})?$/'; // do the test if (!preg_match($pattern, $clean)) { throw new sfValidatorError($this, 'invalid', array('max_right' => $this->getOption('max_right'), 'value' => $value)); } // return the $clean value return $clean; }
protected function doClean($value) { $value = parent::doClean($value); $list = preg_split("#\n|\r#", $value); $clean_list = array(); $clean_list_lower = array(); foreach ($list as $entry) { $entry = trim($entry); if (empty($entry)) { continue; } $lower = mb_strtolower($entry, 'utf-8'); if (in_array($lower, $clean_list_lower, true)) { continue; } $clean_list[] = $entry; $clean_list_lower[] = mb_strtolower($entry, 'utf-8'); } if (empty($clean_list)) { throw new sfValidatorError($this, 'required'); } return $clean_list; }
/** * @see sfValidatorString */ protected function doClean($value) { $clean = parent::doClean($value); $routing = sfContext::getInstance()->getRouting(); $routeInfo = $routing->findRoute($clean); if ($routeInfo) { $module = $routeInfo['parameters']['module']; $action = $routeInfo['parameters']['action']; } else { return $this->getOption('empty_value'); } if ($this->getOption('logout_uri')) { $logoutRouteInfo = $routing->findRoute($this->getOption('logout_uri')); $logoutModule = $logoutRouteInfo['parameters']['module']; $logoutAction = $logoutRouteInfo['parameters']['action']; if ($logoutModule === $module && $logoutAction === $action) { return $this->getOption('empty_value'); } } if (sfConfig::get('sf_login_module') === $module && sfConfig::get('sf_login_action') === $action) { return $this->getOption('empty_value'); } return $clean; }
/** * @see sfValidatorString */ protected function doClean($value) { return parent::doClean(dmString::escape((string) $value)); }
protected function doClean($value) { $clean = parent::doClean($value); return preg_split($this->getOption('demiliter_pattern'), $clean, -1, PREG_SPLIT_NO_EMPTY); }