       else: error :not_multiple, multiple_of: multiple_of
   end
 
-  @spec minimum(number, boolean, number) :: :ok | {:error, map}
-  defp minimum(minimum, _exclusive, value) when value > minimum, do: :ok
-  defp minimum(minimum, true, value) when value == minimum do
-    error :too_small, minimum: minimum, exclusive_minimum: true
-  end
-  defp minimum(minimum, _exclusive, value) when value == minimum, do: :ok
-  defp minimum(minimum, _exclusive, _value) do
-    error :too_small, minimum: minimum
-  end
-
-  @spec maximum(number, boolean, number) :: :ok | {:error, map}
-  defp maximum(maximum, _exclusive, value) when value < maximum, do: :ok
-  defp maximum(maximum, true, value) when value == maximum do
-    error :too_big, maximum: maximum, exclusive_maximum: true
-  end
-  defp maximum(maximum, _exclusive, value) when value == maximum, do: :ok
-  defp maximum(maximum, _exclusive, _value) do
-    error :too_big, maximum: maximum
-  end
-
-  @spec error(atom | Xema.types) :: {:error, map}
-  defp error(atom) when is_atom(atom), do: error atom, []
-  defp error(type), do: error :wrong_type, type: type.as
-
-  @spec error(atom, keyword) :: {:error, map}
-  defp error(reason, info) when is_atom(reason) do
-    info =
-      info
-      |> Enum.into(%{})
-      |> Map.merge(%{reason: reason})
-
-    {:error, info}
-  end
-
   defp min_length(%{min_length: nil}, _), do: :ok
-  defp min_length(%{min_length: min_length}, length)
-       when length >= min_length do
-    :ok
-  end
-  defp min_length(%{min_length: min_length}, _length) do
-    error :too_short, min_length: min_length
+  defp min_length(%{min_length: min}, len) when len >= min, do: :ok
+  defp min_length(%{min_length: min}, _length) do
+    error :too_short, min_length: min
   end
 
   defp max_length(%{max_length: nil}, _length), do: :ok
-  defp max_length(%{max_length: max_length}, length)
-       when length <= max_length do
-    :ok
-  end
-  defp max_length(%{max_length: max_length}, _length) do
-    error :too_long, max_length: max_length
+  defp max_length(%{max_length: max}, len) when len <= max, do: :ok
+  defp max_length(%{max_length: max}, _length) do
+    error :too_long, max_length: max
   end
 
   defp pattern(%{pattern: nil}, _string), do: :ok
   defp pattern(%{pattern: pattern}, string) do
-    if Regex.match?(pattern, string),
-    do: :ok,
-    else: error :no_match, pattern: pattern
+    case Regex.match?(pattern, string) do
+      true -> :ok
+      false -> error :no_match, pattern: pattern
+    end
   end
 
   defp min_items(%Xema.List{min_items: nil}, _list), do: :ok
-  defp min_items(%Xema.List{min_items: min_items}, list)
-    when length(list) < min_items,
-    do: error :too_less_items, min_items: min_items
-  defp min_items(_keywords, _list), do: :ok
+  defp min_items(%Xema.List{min_items: min}, list) when length(list) >= min do
+    :ok
+  end
+  defp min_items(%Xema.List{min_items: min}, _list) do
+    error :too_less_items, min_items: min
+  end
 
   defp max_items(%Xema.List{max_items: nil}, _list), do: :ok
-  defp max_items(%Xema.List{max_items: max_items}, list)
-    when length(list) > max_items,
-    do: error :too_many_items, max_items: max_items
-  defp max_items(_keywords, _list), do: :ok
+  defp max_items(%Xema.List{max_items: max}, list) when length(list) <= max do
+    :ok
+  end
+  defp max_items(%Xema.List{max_items: max}, _list) do
+    error :too_many_items, max_items: max
+  end
 
   defp unique(%Xema.List{unique_items: nil}, _list), do: :ok
   defp unique(%Xema.List{unique_items: true}, list) do
-    if is_unique?(list),
-      do: :ok,
-      else: error :not_unique
+    case is_unique?(list) do
+      true -> :ok
+      false -> error :not_unique
+    end
   end
 
   defp is_unique?(list, set \\ %{})

    value
  ), do: minimum(minimum, exclusive_minimum, value)

  @spec maximum(Xema.types, any) :: :ok | {:error, map}
  defp maximum(%{maximum: nil}, _value), do: :ok
  defp maximum(
    %{maximum: maximum, exclusive_maximum: exclusive_maximum},
    value
  ), do: maximum(maximum, exclusive_maximum, value)

  @spec multiple_of(Xema.types, number) :: :ok | {:error, map}
  defp multiple_of(%{multiple_of: nil} = _keywords, _value), do: :ok

  end

  defp items(%Xema.List{items: nil}, _list), do: :ok
  defp items(
    %Xema.List{items: items, additional_items: additional_items},
    list
  ) when is_list(items), do: items_tuple(items, additional_items, list, 0)
  defp items(%Xema.List{items: items}, list), do: items_list(items, list, 0)

  defp items_list(_schema, [], _at), do: :ok
  defp items_list(schema, [item|list], at) do
