public function onValidate(ValidationEvent $event)
 {
     $config = $event->getConfig();
     $file = $event->getFile();
     if ($file->getSize() > $config['max_size']) {
         throw new ValidationException('error.maxsize');
     }
 }
 public function onValidate(ValidationEvent $event)
 {
     $config = $event->getConfig();
     $file = $event->getFile();
     if (count($config['disallowed_mimetypes']) == 0) {
         return;
     }
     $mimetype = $file->getExtension();
     if (in_array($mimetype, $config['disallowed_mimetypes'])) {
         throw new ValidationException('error.blacklist');
     }
 }
 public function onValidate(ValidationEvent $event)
 {
     $config = $event->getConfig();
     $file = $event->getFile();
     if (count($config['allowed_mimetypes']) == 0) {
         return;
     }
     $mimetype = $file->getMimeType();
     if (!in_array($mimetype, $config['allowed_mimetypes'])) {
         throw new ValidationException('error.whitelist');
     }
 }
 public function onValidate(ValidationEvent $event)
 {
     $config = $event->getConfig();
     $file = $event->getFile();
     if (empty($config['allowed_mimetypes'])) {
         return;
     }
     $mimetype = $file->getMimeType();
     $extension = strtolower($file->getExtension());
     if (!isset($config['allowed_mimetypes'][$mimetype])) {
         throw new ValidationException('error.whitelist');
     }
     if (empty($config['allowed_mimetypes'][$mimetype]) || in_array($extension, $config['allowed_mimetypes'][$mimetype])) {
         return;
     }
     throw new ValidationException('error.whitelist');
 }