       value -> transform_values(rest, options, [{atom_k, value} | acc])
     end
   end
+
+  @spec handle_error(term) :: {:invalid, binary()}
+  defp handle_error(term)
+
+  defp handle_error([missing]) do
+    {:invalid, "`#{missing}` is required, but it's missing"}
+  end
+
+  defp handle_error([_ | _] = missing) do
+    repr = missing |> Enum.map(&"`#{&1}`") |> Enum.reverse() |> Enum.join(", ")
+
+    {:invalid, "#{repr} are required, but they are missing"}
+  end
+
+  defp handle_error({:error, error}) do
+    {:invalid, "header parse error: #{error}"}
+  end
 end

      error ->
        handle_error(error)
    end
  end

  @spec handle_error(term) :: {:invalid, binary()}
  defp handle_error(term)

  defp handle_error([missing]) do
    {:invalid, "`#{missing}` is required, but it's missing"}
  end

  defp handle_error([_ | _] = missing) do
    repr = missing |> Enum.map(&"`#{&1}`") |> Enum.reverse() |> Enum.join(", ")

    {:invalid, "#{repr} are required, but they are missing"}
  end

  defp handle_error({:error, error}) do
    {:invalid, "header parse error: #{error}"}
  end

  @spec extract_header(binary, [binary], boolean) :: extract_ok | extract_err

    end
  end

  @spec find_missing([{binary(), binary()}], [binary()]) :: [binary()]
  defp find_missing(kv_list, req_strings) do
    kv_list |> Enum.map(&elem(&1, 0)) |> do_find_missing(req_strings)
  end

  @spec do_find_missing([binary], [atom], [atom]) :: [atom]
  defp do_find_missing(keys, required, acc \\ [])
  defp do_find_missing(_keys, [], acc), do: acc

  defp do_find_missing(keys, [h | t], acc) do
    if h in keys do
      do_find_missing(keys, t, acc)
    else
      do_find_missing(keys, t, [h | acc])
