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())
3131
3232 public function validate ($ value )
3333 {
34- if ((!isset ($ value ->size ) && $ this -> isDisabled ()) || 0 == $ value ->size && !$ this ->required ) {
34+ if ((!isset ($ value ->size ) || 0 == $ value ->size ) && !$ this ->required ) {
3535 return ;
36- } elseif (!isset ($ value ->size ) && ! $ this ->isDisabled () ) {
36+ } elseif (!isset ($ value ->size ) && $ this ->required ) {
3737 throw new ValidationError (msg ("INVALID_FILE " ), 'invalid ' );
3838 }
3939
Original file line number Diff line number Diff line change @@ -55,6 +55,22 @@ public function testValidateMaxSize()
5555 $ this ->field ->validate ((object ) $ data );
5656 }
5757
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+
5874 public function testToNative ()
5975 {
6076 $ data = array (
You can’t perform that action at this time.
0 commit comments