예제 #1
0
 /**
  * Is Valid
  *
  * @see Zend_Validate_Interface
  */
 public function isValid($value)
 {
     $this->_setValue($value);
     if (!is_array($value)) {
         $this->_error(self::NOT_ARRAY);
         return false;
     }
     $validCount = 0;
     $invalidCount = 0;
     $invalidMax = count($value) - $this->_threshold + 1;
     foreach ($this->value as $v) {
         if ($this->_validator->isValid($v)) {
             ++$validCount;
         } else {
             ++$invalidCount;
         }
         if ($validCount >= $this->_threshold) {
             return true;
         }
         if ($invalidCount >= $invalidMax) {
             $this->_error(self::TOO_FEW);
             return false;
         }
     }
     return true;
 }
예제 #2
0
 /**
  * Is Valid
  *
  * @see Zend_Validate_Interface
  */
 public function isValid($value)
 {
     $this->_setValue($value);
     if (!is_array($value)) {
         $this->_error(self::NOT_ARRAY);
         return false;
     }
     foreach ($value as $elem) {
         if (!$this->validator->isValid($elem)) {
             // The validator's errors will available through this class's
             // error-retreiving methods to preserve transparency
             return false;
         }
     }
     return true;
 }
예제 #3
0
 /**
  *
  * @param array $event
  * @return bool
  */
 public function accept($event)
 {
     if (null === $this->_key) {
         $validationData = $event;
     } elseif (isset($event[$this->_key])) {
         $validationData = $event[$this->_key];
     } else {
         $message = 'key "' . $this->_key . '" not found in event';
         throw new Robo47_Log_Filter_Exception($message);
     }
     if (true === $this->_not) {
         return !$this->_validator->isValid($validationData);
     } else {
         return $this->_validator->isValid($validationData);
     }
 }
예제 #4
0
 /**
  * Is Valid
  *
  * @see Zend_Validate_Interface
  */
 public function isValid($value)
 {
     $this->_setValue($value);
     if (!is_array($value)) {
         $this->_error(self::NOT_ARRAY);
         return false;
     }
     $validCount = 0;
     foreach ($this->value as $v) {
         if ($this->_validator->isValid($v)) {
             $validCount++;
         }
         if ($validCount > $this->_threshold) {
             $this->_error(self::TOO_MANY);
             return false;
         }
     }
     return true;
 }
 /**
  * Checks if the values of the two form elements fulfill the relation.
  *
  * @param mixed $value
  * @param array(string=>string)|null $context
  * @return boolean True if the element relation is fulfilled, false otherwise.
  */
 public function isValid($value, $context = null)
 {
     $this->_setValue($value);
     $this->rawCompareValue = null;
     if ($context === null) {
         $this->_error(self::NO_CONTEXT);
         return false;
     }
     if (!is_array($context)) {
         $this->_error(self::INVALID_CONTEXT);
         return false;
     }
     if (!isset($context[$this->getCompareName()])) {
         $this->_error(self::NO_COMPARE_VALUE);
         return false;
     }
     $this->rawCompareValue = $context[$this->getCompareName()];
     if (!$this->relation->isValid($value, $this->rawCompareValue)) {
         $this->addMessages($this->relation->getMessages());
         return false;
     }
     return true;
 }
예제 #6
0
파일: Validator.php 프로젝트: mage2pro/core
 /**
  * 2015-04-05
  * Пока никем извне класса не используется, но будет.
  * @used-by checkProperty()
  * @param mixed $value
  * @param \Zend_Validate_Interface $validator
  * @throws \Df\Core\Exception
  * @return bool
  */
 public static function validate($value, \Zend_Validate_Interface $validator)
 {
     return is_null($value) && isset($validator->{self::$SKIP_ON_NULL}) && $validator->{self::$SKIP_ON_NULL} || $validator->isValid($value);
 }
예제 #7
0
파일: Method.php 프로젝트: mage2pro/core
 /**
  * @param \Zend_Validate_Interface $validator
  * @param mixed $paramValue
  * @param int $paramOrdering
  * @param int $stackLevel
  * @return void
  * @throws \Exception
  */
 public static function validateParam(\Zend_Validate_Interface $validator, $paramValue, $paramOrdering, $stackLevel = 1)
 {
     if (!$validator->isValid($paramValue)) {
         self::raiseErrorParam($validatorClass = get_class($validator), $messages = $validator->getMessages(), $paramOrdering, ++$stackLevel);
     }
 }
예제 #8
0
 /**
  * Call the decorated validator. This method is called by Opus_Validate_AbstractMate::isValid(). 
  *
  * @param mixed $value Value to validate.
  * @return boolean Whatever the decorated validators isValid() method returns.
  */
 protected function _isValid($value)
 {
     return $this->_decorated->isValid($value);
 }
예제 #9
0
 /**
  * Return cookie value "as is" as long as it exists and passes the validation
  *
  * @param string $cookieName
  * @param Zend_Validate_Interface $validator
  * @return string|bool
  */
 protected static function _getValidCookieValue($cookieName, Zend_Validate_Interface $validator)
 {
     if (isset($_COOKIE[$cookieName]) && $validator->isValid($_COOKIE[$cookieName])) {
         return $_COOKIE[$cookieName];
     }
     return false;
 }
예제 #10
0
파일: Adapter.php 프로젝트: cwcw/cms
 /**
  * Calls the adaptee's isValid method
  *
  * @see Specification/Streamwide_Specification_Abstract#isSatisfiedBy($candidate)
  */
 public function isSatisfiedBy($candidate)
 {
     return $this->_adaptee->isValid($candidate);
 }