File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,9 @@ public function __construct(array $args = array())
31
31
32
32
public function validate ($ value )
33
33
{
34
- if ((!isset ($ value ->size ) && $ this -> isDisabled ()) || 0 == $ value ->size && !$ this ->required ) {
34
+ if ((!isset ($ value ->size ) || 0 == $ value ->size ) && !$ this ->required ) {
35
35
return ;
36
- } elseif (!isset ($ value ->size ) && ! $ this ->isDisabled () ) {
36
+ } elseif (!isset ($ value ->size ) && $ this ->required ) {
37
37
throw new ValidationError (msg ("INVALID_FILE " ), 'invalid ' );
38
38
}
39
39
Original file line number Diff line number Diff line change @@ -55,6 +55,22 @@ public function testValidateMaxSize()
55
55
$ this ->field ->validate ((object ) $ data );
56
56
}
57
57
58
+ public function testValidateNull ()
59
+ {
60
+ $ result = $ this ->field ->validate (null );
61
+ $ this ->assertNull ($ result );
62
+ }
63
+
64
+ /**
65
+ * @expectedException PHPForm\Exceptions\ValidationError
66
+ * @expectedExceptionMessage Invalid file submitted.
67
+ */
68
+ public function testValidateInvalid ()
69
+ {
70
+ $ field = new FileField (["max_size " => 20 , 'required ' => true ]);
71
+ $ field ->validate (null );
72
+ }
73
+
58
74
public function testToNative ()
59
75
{
60
76
$ data = array (
You can’t perform that action at this time.
0 commit comments