Example #1
0
 /**
  * Validate
  *
  * @param  \Upload\FileInfoInterface  $fileInfo
  * @throws \RuntimeException          If validation fails
  */
 public function validate(FileInfoInterface $fileInfo)
 {
     $fileSize = $fileInfo->getSize();
     if ($fileSize < $this->minSize) {
         throw new Exception(sprintf('File size is too small. Must be greater than or equal to: %s', $this->minSize), $fileInfo);
     }
     if ($fileSize > $this->maxSize) {
         throw new Exception(sprintf('File size is too large. Must be less than: %s', $this->maxSize), $fileInfo);
     }
 }