     end
   end
 
-  defp additionals(_schema, _map), do: :ok
-
-  @spec dependencies(Xema.Schema.t(), map) :: result
-  defp dependencies(%{dependencies: nil}, _map), do: :ok
-
-  defp dependencies(%{dependencies: dependencies}, map) do
+  defp additionals(_schema, _map, _opts), do: :ok
+
+  @spec dependencies(Xema.Schema.t(), map, keyword) :: result
+  defp dependencies(%{dependencies: nil}, _map, _opts), do: :ok
+
+  defp dependencies(%{dependencies: dependencies}, map, opts) do
     dependencies
     |> Map.to_list()
     |> Enum.filter(fn {key, _} -> has_key?(map, key) end)
-    |> do_dependencies(map)
-  end
-
-  @spec do_dependencies(list, map) :: result
-  defp do_dependencies([], _map), do: :ok
-
-  defp do_dependencies([{key, list} | tail], map) when is_list(list) do
-    with :ok <- do_dependencies_list(key, list, map) do
-      do_dependencies(tail, map)
+    |> do_dependencies(map, opts)
+  end
+
+  @spec do_dependencies(list, map, keyword) :: result
+  defp do_dependencies([], _map, _opts), do: :ok
+
+  defp do_dependencies([{key, list} | tail], map, opts) when is_list(list) do
+    with :ok <- do_dependencies_list(key, list, map, opts) do
+      do_dependencies(tail, map, opts)
     end
   end
 

    end
  end

  @spec do_not(Xema.Schema.t(), any) :: result
  defp do_not(%{not: nil}, _value), do: :ok

  defp do_not(%{not: schema}, value) do
    case validate(schema, value) do
      :ok -> {:error, :not}
      _ -> :ok
    end
  end

  @spec all_of(Xema.Schema.t(), any) :: result
  defp all_of(%{all_of: nil}, _value), do: :ok

  defp all_of(%{all_of: schemas}, value) do
    case do_all_of(schemas, value) do
      true -> :ok
      false -> {:error, :all_of}
    end
  end

  @spec do_all_of(list, any) :: boolean
  defp do_all_of(schemas, value),
    do: Enum.all?(schemas, fn schema -> validate(schema, value) == :ok end)

  @spec any_of(Xema.Schema.t(), any) :: result
  defp any_of(%{any_of: nil}, _value), do: :ok

  defp any_of(%{any_of: schemas}, value) do
    case do_any_of(schemas, value) do
      true -> :ok
      false -> {:error, :any_of}
    end
  end

  @spec do_any_of(list, any) :: boolean
  defp do_any_of(schemas, value),
    do: Enum.any?(schemas, fn schema -> validate(schema, value) == :ok end)

  @spec one_of(Xema.Schema.t(), any) :: result
  defp one_of(%{one_of: nil}, _value), do: :ok

  defp one_of(%{one_of: schemas}, value) do
    case do_one_of(schemas, value) == 1 do
      true -> :ok
      false -> {:error, :one_of}
    end
  end

  @spec do_one_of(list, any) :: integer
  defp do_one_of(schemas, value) do
    schemas
    |> Enum.filter(fn schema ->
      case validate(schema, value) do
        :ok -> true
        {:error, _} -> false
      end

         additional_items,
         [item | list],
         at,
         errors,
         opts
       ) do
    case validate(schema, item, opts) do
      :ok ->
        items_tuple(schemas, additional_items, list, at + 1, errors, opts)

      {:error, reason} ->
        items_tuple(schemas, additional_items, list, at + 1, [
          {at, reason} | errors
        ], opts)
    end
  end

