Skip to content

Commit

Permalink
fix validations
Browse files Browse the repository at this point in the history
  • Loading branch information
lodev09 committed Feb 4, 2019
1 parent 48efd5b commit c20720e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,18 @@ public function validate() {

// filter extension
if ($this->_validations['extensions']) {
$extensions = $this->_validations['extensions'];
$def_ext_filter = [
'is' => [],
'not' => [],
'message' => '[extension: '.$this->extension.'] '.$this->_error_messages[self::UPLOAD_ERR_EXTENSION_FILTER]
];
$ext_filter = Util::set_values($def_ext_filter, $this->_validations['extensions'], 'is');

if (is_array($extensions) && is_int(key($extensions))) {
$extensions['is'] = $extensions;
}

$ext_filter = Util::set_values($def_ext_filter, $extensions, 'is');
$this->set_error_message(self::UPLOAD_ERR_EXTENSION_FILTER, $ext_filter['message']);

if (!is_array($ext_filter['is'])) $ext_filter['is'] = [$ext_filter['is']];
Expand All @@ -260,13 +266,19 @@ public function validate() {

// filter category
if ($this->_validations['categories']) {
$categories = $this->_validations['categories'];

$def_cat_filter = [
'is' => [],
'not' => [],
'message' => '[category: '.$this->category.'] '.$this->_error_messages[self::UPLOAD_ERR_CATEGORY_FILTER]
];

$cat_filter = Util::set_values($def_cat_filter, $this->_validations['categories'], 'is');
if (is_array($categories) && is_int(key($categories))) {
$categories['is'] = $categories;
}

$cat_filter = Util::set_values($def_cat_filter, $categories, 'is');
$this->set_error_message(self::UPLOAD_ERR_CATEGORY_FILTER, $cat_filter['message']);

if (!is_array($cat_filter['is'])) $cat_filter['is'] = [$cat_filter['is']];
Expand Down

0 comments on commit c20720e

Please sign in to comment.