     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
+  @spec do_not(Xema.Schema.t(), any, keyword) :: result
+  defp do_not(%{not: nil}, _value, _opts), do: :ok
+
+  defp do_not(%{not: schema}, value, opts) do
+    case validate(schema, value, opts) 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
+  @spec all_of(Xema.Schema.t(), any, keyword) :: result
+  defp all_of(%{all_of: nil}, _value, _opts), do: :ok
+
+  defp all_of(%{all_of: schemas}, value, opts) do
+    case do_all_of(schemas, value, opts) 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
+  @spec do_all_of(list, any, keyword) :: boolean
+  defp do_all_of(schemas, value, opts),
+    do: Enum.all?(schemas, fn schema -> validate(schema, value, opts) == :ok end)
+
+  @spec any_of(Xema.Schema.t(), any, keyword) :: result
+  defp any_of(%{any_of: nil}, _value, _opts), do: :ok
+
+  defp any_of(%{any_of: schemas}, value, opts) do
+    case do_any_of(schemas, value, opts) 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
+  @spec do_any_of(list, any, keyword) :: boolean
+  defp do_any_of(schemas, value, opts),
+    do: Enum.any?(schemas, fn schema -> validate(schema, value, opts) == :ok end)
+
+  @spec one_of(Xema.Schema.t(), any, keyword) :: result
+  defp one_of(%{one_of: nil}, _value, _opts), do: :ok
+
+  defp one_of(%{one_of: schemas}, value, opts) do
+    case do_one_of(schemas, value, opts) == 1 do
       true -> :ok
       false -> {:error, :one_of}
     end
   end
 
-  @spec do_one_of(list, any) :: integer
-  defp do_one_of(schemas, value) do
+  @spec do_one_of(list, any, keyword) :: integer
+  defp do_one_of(schemas, value, opts) do
     schemas
     |> Enum.filter(fn schema ->
-      case validate(schema, value) do
+      case validate(schema, value, opts) do
         :ok -> true
         {:error, _} -> false
       end

    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
    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)
    end
  end


  #  end
  # end

  defp do_dependencies([{key, schema} | tail], map, opts) do
    case validate(schema, map, opts) do
      :ok ->
        do_dependencies(tail, map, opts)

      {:error, reason} ->
        {:error, %{dependencies: %{key => reason}}}
    end
  end

  @spec do_dependencies_list(String.t() | atom, list, map, keyword) :: result
  defp do_dependencies_list(_key, [], _map, _opts), do: :ok

  defp do_dependencies_list(key, [dependency | dependencies], map, opts) do
    case has_key?(map, dependency) do
      true ->
        do_dependencies_list(key, dependencies, map, opts)

      false ->
        {:error, %{dependencies: %{key => dependency}}}
