Example #1
0
 /**
  * TODO: make a better name
  *
  * @param  mixed|null $message
  * @return Result
  */
 protected function _bad($message = null)
 {
     $result = new Result(false);
     if ($message) {
         $result->addErrorMessage($message);
     }
     return $result;
 }
Example #2
0
 /**
  * Проверка валидности значения
  *
  * @param  mixed $value
  * @return Result
  */
 function validate($value)
 {
     $result = new Result(true);
     foreach ($this->_validators as $validator) {
         /**
          * @var IValidator $validator
          */
         $result->mergeWithResult($validator->validate($value));
     }
     return $result;
 }
Example #3
0
 /**
  * @param  mixed $value
  * @return Result
  */
 public function validate($value)
 {
     $result = new Result(true);
     foreach ($this->_validators as $validator) {
         /**
          * @var IValidator $validator
          */
         if ($validator->validate($value)->isValid()) {
             return $this->_ok();
         } else {
             $result->mergeWithResult($validator->validate($value));
         }
     }
     $result->setInvalid();
     return $result->addErrorMessage("Должно быть выполнено хотя бы одно условие");
 }