Browse Source

Don't allow [] in file fields.

Like '', an empty array is not an acceptable empty state for a file
upload field. The `[]` value should be passed onto other validator
rules as it is likely not valid.
Mark Story 7 years ago
parent
commit
0790ace7d1
2 changed files with 2 additions and 2 deletions
  1. 1 1
      src/Validation/Validator.php
  2. 1 1
      tests/TestCase/Validation/ValidatorTest.php

+ 1 - 1
src/Validation/Validator.php

@@ -2339,7 +2339,7 @@ class Validator implements ArrayAccess, IteratorAggregate, Countable
             return true;
         }
 
-        $arrayTypes = self::EMPTY_ARRAY | self::EMPTY_DATE | self::EMPTY_TIME | self::EMPTY_FILE;
+        $arrayTypes = self::EMPTY_ARRAY | self::EMPTY_DATE | self::EMPTY_TIME;
         if ($data === [] && ($flags & $arrayTypes)) {
             return true;
         }

+ 1 - 1
tests/TestCase/Validation/ValidatorTest.php

@@ -913,7 +913,7 @@ class ValidatorTest extends TestCase
 
         $data = ['photo' => []];
         $result = $validator->errors($data);
-        $this->assertEmpty($result);
+        $this->assertSame($expected, $result);
 
         $validator = new Validator();
         $validator->allowEmptyArray('photo', 'update', 'message');