Form API multiplie file upload validation error
This happened to me today. After some research it's appear that Drupal8 have a bug with empty file form element when this one is multiple.

The file_save_upload function expects an array looks like this when element is empty :

 ['form_field_name' =&gt; NULL]


But actually for an empty multiple file form element the array is:

 ['form_field_name' =&gt; [0 =&gt; NULL]]


So the condition check for an empty value and fail. The code continue until it try to use getError() on a null value.

Here is a function to check if a file were uploaded or not. You can use it in the validateForm callback of your form class or in a hook.

function isFileUploaded($form_field_name) {
  $all_files = \Drupal::request()-&gt;files-&gt;get('files', array());

  return isset($all_files[$form_field_name]) &amp;&amp;
    !empty($all_files[$form_field_name]) &amp;&amp;
    NULL !== reset($all_files[$form_field_name]);
}


It's not very pretty but it'll work until they fix that bug.