public static function isValid($validation, $fieldname) {
    // No validation means you dont want to validate, so return affirmative.
    if (!$validation) {
      return true;
    }

    // Get filename.
    $filename = explode(".", $_FILES[$fieldname]["name"]);

    // Validate uploaded files.
    // Do not use $_FILES["file"]["type"] as it can be easily forged.
    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $mimeType = self::getMimeType($_FILES[$fieldname]["tmp_name"]);

    // Validation is a function provided by the user.
    if ($validation instanceof \Closure) {
        return $validation($_FILES[$fieldname]["tmp_name"], $mimeType);
    }

    if (is_array($validation)) {
      return self::isFileValid($filename, $mimeType, $validation['allowedExts'], $validation['allowedMimeTypes']);
    }

    // Else: no specific validating behaviour found.
    return false;
  }