/** * @see sfValidatorString */ protected function doClean($value) { if (!array_key_exists($this->getOption('algorithm'), $this->algorithms)) { throw new LogicException(__CLASS__ . ' does not support this algorithm'); } $algorithm = $this->algorithms[$this->getOption('algorithm')]; $this->setOption('pattern', '/^[a-f0-9]{' . $algorithm['length'] . '}$/i'); return parent::doClean($value); }
/** * @see sfValidatorRegex */ protected function doClean($value) { $clean = parent::doClean($value); $value = (double) $value; if ($value < 0 || $value > 8000) { throw new sfValidatorError($this, 'out_of_range', array('value' => $value)); } return $clean; }
protected function doClean($value) { $clean = parent::doClean($value); if ($this->getOption('check_domain') && function_exists('checkdnsrr')) { $tokens = explode('@', $clean); if (!checkdnsrr($tokens[1], 'MX') && !checkdnsrr($tokens[1], 'A')) { throw new sfValidatorError($this, 'invalid', array('value' => $clean)); } } return $clean; }
/** * @see sfValidatorString */ protected function doClean($value) { $value = parent::doClean($value); // replace spaces with dots $value = str_replace(' ', '.', trim($value)); // replace .. and .# with . $value = preg_replace('|\\.([\\.\\#]+)|', '', $value); // must start with a . or a # if (!empty($value) && $value[0] !== '.' && $value[0] !== '#') { $value = '.' . $value; } return $value; }
protected function doClean($value) { //Truncar valor antes $clean = trim((string) $value); parent::doClean($clean); $length = function_exists('mb_strlen') ? mb_strlen($clean, $this->getCharset()) : strlen($clean); if ($this->hasOption('required') && $length == 0) { throw new sfValidatorError($this, 'required', array('value' => $value, 'required' => $this->getOption('required'))); } if ($this->hasOption('max_length') && $length > $this->getOption('max_length')) { throw new sfValidatorError($this, 'max_length', array('value' => $value, 'max_length' => $this->getOption('max_length'))); } return $clean; }
/** * * value should be array * array('dynamic-bootp 0.0.0.0 0.0.0.0') * or * array('0.0.0.0 0.0.0.0') * * @see sfValidatorBase */ protected function doClean($value) { $choices = $this->getOption('choices'); if ($choices instanceof sfCallable) { $choices = $choices->call(); } if (!is_array($value)) { throw new sfValidatorError($this, 'type_error'); } $match_bootp = '/^' . self::$bootp_flag . '/'; foreach ($value as $v) { if (preg_match($match_bootp, $v)) { $ranges_data = explode(' ', $v, 3); if (count($ranges_data) != 3) { throw new sfValidatorError($this, 'invalid', array('value' => $v)); } $dyn_bootp = $ranges_data[0]; $from_ip = $ranges_data[1]; $to_ip = $ranges_data[2]; $validate_bootp = new sfValidatorRegex(array('pattern' => '#^' . self::$bootp_flag . '#'), array('invalid' => $this->getMessage('invalid'))); $validate_bootp->doClean($dyn_bootp); // should be dynamic bootp flag $ip = new ValidatorIP(); $ip->doClean($from_ip); $ip->doClean($to_ip); } else { $ranges_data = explode(' ', $v, 2); if (count($ranges_data) != 2) { throw new sfValidatorError($this, 'invalid', array('value' => $v)); } $from_ip = $ranges_data[0]; $to_ip = $ranges_data[1]; $ip = new ValidatorIP(); $ip->doClean($from_ip); $ip->doClean($to_ip); } } return $value; }
/** * @see sfValidatorString */ protected function doClean($value) { $value = parent::doClean($value); $value = trim(str_replace('.', ' ', $value)); return $value; }
/** * @see sfValidatorString */ protected function doClean($value) { $clean = md5(parent::doClean($value)); return $clean; }