original_string: protected function _validate(Model $model, $data, $method, array $params) {
          foreach ($data as $field => $value) {
              if ($this->_allowEmpty($model, $field, $value)) {
                  return true;
  
              } else if ($this->_isEmpty($value)) {
                  return false;
              }
  
              $file = null;
  
              // Upload, use temp file
              if (is_array($value)) {
                  $file = new File($value);
  
              // Import, copy file for validation
              } else if (!empty($value)) {
                  $target = md5($value);
  
                  $transit = new Transit($value);
                  $transit->setDirectory(TMP);
  
                  // Already imported from previous validation
                  if (isset($this->_tempFiles[$target])) {
                      $file = $this->_tempFiles[$target];
  
                  // Local file
                  } else if (file_exists($value)) {
                      if ($transit->importFromLocal()) {
                          $file = $transit->getOriginalFile();
                          $file->rename($target);
                      }
  
                  // Attempt to copy from remote
                  } else if (preg_match('/^http/i', $value)) {
                      if ($transit->importFromRemote()) {
                          $file = $transit->getOriginalFile();
                          $file->rename($target);
                      }
  
                  // Or from stream
                  } else {
                      if ($transit->importFromStream()) {
                          $file = $transit->getOriginalFile();
                          $file->rename($target);
                      }
                  }
  
                  // Save temp so we can delete later
                  if ($file && !isset($this->_tempFiles[$target])) {
                      $this->_tempFiles[$target] = $file;
                  }
              }
  
              if (!$file) {
                  $this->log(sprintf('Invalid upload or import for validation: %s', json_encode($value)), LOG_DEBUG);
                  return false;
              }
  
              $validator = new ImageValidator();
              $validator->setFile($file);
  
              return call_user_func_array(array($validator, $method), $params);
          }
  
          return false;
      }
code: protected function _validate(Model $model, $data, $method, array $params) {
          foreach ($data as $field => $value) {
              if ($this->_allowEmpty($model, $field, $value)) {
                  return true;
  
              } else if ($this->_isEmpty($value)) {
                  return false;
              }
  
              $file = null;
  
              // Upload, use temp file
              if (is_array($value)) {
                  $file = new File($value);
  
              // Import, copy file for validation
              } else if (!empty($value)) {
                  $target = md5($value);
  
                  $transit = new Transit($value);
                  $transit->setDirectory(TMP);
  
                  // Already imported from previous validation
                  if (isset($this->_tempFiles[$target])) {
                      $file = $this->_tempFiles[$target];
  
                  // Local file
                  } else if (file_exists($value)) {
                      if ($transit->importFromLocal()) {
                          $file = $transit->getOriginalFile();
                          $file->rename($target);
                      }
  
                  // Attempt to copy from remote
                  } else if (preg_match('/^http/i', $value)) {
                      if ($transit->importFromRemote()) {
                          $file = $transit->getOriginalFile();
                          $file->rename($target);
                      }
  
                  // Or from stream
                  } else {
                      if ($transit->importFromStream()) {
                          $file = $transit->getOriginalFile();
                          $file->rename($target);
                      }
                  }
  
                  // Save temp so we can delete later
                  if ($file && !isset($this->_tempFiles[$target])) {
                      $this->_tempFiles[$target] = $file;
                  }
              }
  
              if (!$file) {
                  $this->log(sprintf('Invalid upload or import for validation: %s', json_encode($value)), LOG_DEBUG);
                  return false;
              }
  
              $validator = new ImageValidator();
              $validator->setFile($file);
  
              return call_user_func_array(array($validator, $method), $params);
          }
  
          return false;
      }
code_tokens: protected function _validate ( Model $ model , $ data , $ method , array $ params ) { foreach ( $ data as $ field => $ value ) { if ( $ this -> _allowEmpty ( $ model , $ field , $ value ) ) { return true ; } else if ( $ this -> _isEmpty ( $ value ) ) { return false ; } $ file = null ; // Upload, use temp file if ( is_array ( $ value ) ) { $ file = new File ( $ value ) ; // Import, copy file for validation } else if ( ! empty ( $ value ) ) { $ target = md5 ( $ value ) ; $ transit = new Transit ( $ value ) ; $ transit -> setDirectory ( TMP ) ; // Already imported from previous validation if ( isset ( $ this -> _tempFiles [ $ target ] ) ) { $ file = $ this -> _tempFiles [ $ target ] ; // Local file } else if ( file_exists ( $ value ) ) { if ( $ transit -> importFromLocal ( ) ) { $ file = $ transit -> getOriginalFile ( ) ; $ file -> rename ( $ target ) ; } // Attempt to copy from remote } else if ( preg_match ( '/^http/i' , $ value ) ) { if ( $ transit -> importFromRemote ( ) ) { $ file = $ transit -> getOriginalFile ( ) ; $ file -> rename ( $ target ) ; } // Or from stream } else { if ( $ transit -> importFromStream ( ) ) { $ file = $ transit -> getOriginalFile ( ) ; $ file -> rename ( $ target ) ; } } // Save temp so we can delete later if ( $ file && ! isset ( $ this -> _tempFiles [ $ target ] ) ) { $ this -> _tempFiles [ $ target ] = $ file ; } } if ( ! $ file ) { $ this -> log ( sprintf ( 'Invalid upload or import for validation: %s' , json_encode ( $ value ) ) , LOG_DEBUG ) ; return false ; } $ validator = new ImageValidator ( ) ; $ validator -> setFile ( $ file ) ; return call_user_func_array ( array ( $ validator , $ method ) , $ params ) ; } return false ; }
docstring: Validate the field against the validation rules.
  
  @uses Transit\Transit
  @uses Transit\File
  @uses Transit\Validator\ImageValidator
  
  @param Model $model
  @param array $data
  @param string $method
  @param array $params
  @return bool
  @throws UnexpectedValueException
docstring_tokens: Validate the field against the validation rules .